Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Polymorphic help and static/dynamic cast

$
0
0
Hey all,

So I have the following code
if(static_cast<cBlock*>(&ObjVec[t]))
{
	ObjVec[t].FreeMe();
}



cBlock is the derived class of what is stored in ObjVec.

Shouldn't the FreeMe function be called by the derived class. In the header it is set as a virtual function. I know that this element being tested in the static cast is on instance of cBlock. the use of dynamic_cast resulted in at false result in the if statement.

all guidance would be appreciated.

~Xtreampb~

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>