Skip to content

Commit 8755c27

Browse files
committed
Add dynamic_pointer_cast
1 parent 4f0a5ee commit 8755c27

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ x++ // Add 1 to x, evaluates to original x (postfix)
180180
x-- // Subtract 1 from x, evaluates to original x
181181
typeid(x) // Type of x
182182
typeid(T) // Equals typeid(x) if x is a T
183-
dynamic_cast< T>(x) // Converts x to a T, checked at run time
183+
dynamic_cast< T>(x) // Converts x to a T, checked at run time.
184184
static_cast< T>(x) // Converts x to a T, not checked
185185
reinterpret_cast< T>(x) // Interpret bits of x as a T
186186
const_cast< T>(x) // Converts x to same type T but not const
@@ -337,6 +337,9 @@ if (z == nullptr){
337337
cout << "Z null";
338338
}
339339
cout << *q;
340+
shared_ptr<B> r;
341+
r = dynamic_pointer_cast<B>(t); // Converts t to a shared_ptr<B>
342+
340343
```
341344

342345
## `math.h`, `cmath` (floating point math)

0 commit comments

Comments
 (0)