C++ is static typed language, why can we get type at runtime -
type& dynamic_cast<type&> (object); type* dynamic_cast<type*> (object);
for example can type this. c++ static typed language, why can type @ runtime
variables in c++ have statically determined type. objects don't necessarily. need handle objects through variables of statically known type.
examples:
int * p = new int[argc]; // there object dynamic type int[argc] base * p = new derived; // *p has dynamic type derived base * q = rand() % 2 ? new derived1 : new derived2; // ???
Comments
Post a Comment