mirror of
https://github.com/DevEhChad/cpp-cheatsheet.git
synced 2025-11-08 14:01:34 +00:00
Add dynamic_pointer_cast
This commit is contained in:
@@ -180,7 +180,7 @@ x++ // Add 1 to x, evaluates to original x (postfix)
|
|||||||
x-- // Subtract 1 from x, evaluates to original x
|
x-- // Subtract 1 from x, evaluates to original x
|
||||||
typeid(x) // Type of x
|
typeid(x) // Type of x
|
||||||
typeid(T) // Equals typeid(x) if x is a T
|
typeid(T) // Equals typeid(x) if x is a T
|
||||||
dynamic_cast< T>(x) // Converts x to a T, checked at run time
|
dynamic_cast< T>(x) // Converts x to a T, checked at run time.
|
||||||
static_cast< T>(x) // Converts x to a T, not checked
|
static_cast< T>(x) // Converts x to a T, not checked
|
||||||
reinterpret_cast< T>(x) // Interpret bits of x as a T
|
reinterpret_cast< T>(x) // Interpret bits of x as a T
|
||||||
const_cast< T>(x) // Converts x to same type T but not const
|
const_cast< T>(x) // Converts x to same type T but not const
|
||||||
@@ -337,6 +337,9 @@ if (z == nullptr){
|
|||||||
cout << "Z null";
|
cout << "Z null";
|
||||||
}
|
}
|
||||||
cout << *q;
|
cout << *q;
|
||||||
|
shared_ptr<B> r;
|
||||||
|
r = dynamic_pointer_cast<B>(t); // Converts t to a shared_ptr<B>
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## `math.h`, `cmath` (floating point math)
|
## `math.h`, `cmath` (floating point math)
|
||||||
|
|||||||
Reference in New Issue
Block a user