Number Type Cast
Solved
C++ Gurus
-
@beecksche said in Number Type Cast:
MyDerivedClass derived = static_cast<MyDerivedClass>(base);
Just one note: static_cast has absolutely no notion of safety. There's no check involved so you are completely responsible to ensure that the type you are casting to is really is valid with regard to the type you are casting from.
dynamic_cast
does check and in the case of pointers return a null pointer that you can validate before continuing your code.wrote on 9 Apr 2019, 03:15 last edited by
21/21