Thursday, December 4, 2008

Dynamic Casting


dynamic_cast

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(b);

0 comments:

Hit Counter


Statistics

Followers

 

Programmer's Guide. Copyright 2008 All Rights Reserved