Say that I that I have these classes:
struct Parent {};
struct Child : public Parent {
void func() {}
};
Now say that I wanted to create a function like this:
void foo(Parent* arg) {
auto child = dynamic_cast<Child*>(arg);
if(child != nullptr) child->func();
}
But obviously that will obviously give me the error:
dynamic_cast
:Parent
is not a polymorphic type
So I can't do the dynamic_cast
step, is there a way that I can validate that arg
is in fact a Child*
at run-time?