What is the difference between dynamic and static casting?static_cast are used in two cases :
1) for implicit casts that the compiler would make automatically anyway (bool to int) 2) as a mandatory forced cast (float to int).
- The dynamic_cast is unique to C++. It is used at runtime when info is required to make the proper cast. - For example, when you downcast a base class pointer to a derived class.
|