Unrestricted explicit type-casting allows to convert any pointer into any
other pointer type, independently of the types they point to. (syntax and
compiling is right, but cause runtime error).
There are three operators, dynamic_cast, const_cast and static_cast. You
should use dynamic_cast, static_cast and const_cast firstly in C++. Why?
see below explanation.
dynamic_cast use to cast down a base pointer to child pointer.
dynamic_cast assure that down cast is valid. Because you can always safely
assign child pointer to base pointer in C++. (That is how polymorphic
implement.) const_cast will remove cast feature.
static_cast<type-name> expression will be valid only if type-name can be
converted implicitly to the same type that expression has. It will stop you
from change a bird class to an apple class which are two totally
unrelated classes. Even change int to double, encourage you to use
static_cast<double>(i). it also can help you to find cast easily in you source
code by search "static_cast".