Status
Not open for further replies.
Sep 29, 2004
18,656
68
91
IGNORE ..... wrong forum again.













Obviously I would never do this, but for the love of code maintenance I have to ask. Assume you have the following code Where Foo is a child of base class BaseClass

-----------------

Foo* foo = null;

if( dynamic_cast<BaseClass>( foo ) )
return dynamic_cast<BaseClass>( foo );
else
// print error message


-----------------

My assumption is that dyamic_cast<> would die a fiery death so that else function is pointless.

Since this is a static system that I am dealing with, foo is defined by performing a look up. The else branch always occurs or never occurs. Which means that nothing bad has ever happened in the deployed environment. But code like this really angers me.

back to the question: What would happen in the code I gave above?
 
Status
Not open for further replies.