dynamic_cast is used to do downcasting, means to assign a base class pointer to it's derived class pointer.
Ex:
class base
{
};
class derived :: public base
{
}
base* b = new derived; //this is upcasting and allowed
but....
derived* d = b; //this is downcasting and not allowed directly
so here dynamic casting is used
derived* d = dynamic_cast

0 comments:
Post a Comment