Click to See Complete Forum and Search --> : What is <dynamic_cast>


anand_gore
May 18th, 1999, 09:47 AM
The &lt;dyanmic_cast&gt; and &lt;static_cast&gt; are MACROS rite??
I want the listing of this...
Or else i want its functionality....I want that how it actually type casts the thing.....
Please help me...
Thanks
Anand

chiuyan
May 18th, 1999, 10:20 AM
dynamic_cast & static_cast are operators, not macros.

static_cast & dynamic_cast simply cast the desired object to the desired type. dynamic_cast, however, is able to perform some runtime checking and will return NULL if the desired object cannot be cast to the desire type--static_cast will always cast it, regardless of whether or not it makes sense (this could be dangerous). Because the static_cast does not do type checking, it is more dangerous to use, but it is also faster. So if you know what you are casting is okay, then use static_cast.

--michael