Forgot to enable RTTI. Thanks...
ignore post
Printable View
Forgot to enable RTTI. Thanks...
ignore post
Why don't you just scan the page from your homework book and we can see the whole thing and maybe do the next question for you, too.
Or we can be rude and be of no help. thanks ass.
Yes, I am working on a lab. If you read I didnt ask for someone to do it for me. The lab has to do with getting user input for derived classes and store them into a base class pointer. I have already done that, im trying to take it further to figure out how somet things work. I asked what is going on so i can understand how to use dynamic_cast better.
where do I enable RTTI? That is probably where my problem is.
dynamic_cast is used as follows:
generally, dynamic_cast should be avoided. there are almost always better ways of doing the same thing (virtual functions, etc)Code:
class base
{
};
class derived : public base
{
};
void func(base& b)
{
derived* pd = dynamic_cast<derived*>(&b);
if (pd)
{
cout << "it's a derived class!";
}
}