I am trying to understand how dynamic_cast works. I have a class interfaceElement with a class menu derived from it. In my program, I create no objects of class interfaceElement. When executing the following code (executing the line with dynamic_cast, to be more precise), the bad_cast exception is thrown
void drawInterfaceElement(interfaceElement elem, int colour1, int colour2)
{
if (elem.getType()=="MENU")
{
menu &cur = dynamic_cast<menu&>(elem);
this->drawMenu(&cur,colour1,colour2);
}
}
Why?