We have a method which is being passed a class as an argument. This class has different child classes. We need to know which of those classes is the one who is being passed as an argument to this method. We can't define one method for each of the possible classes due to assignment requirements. Furthermore, if the child class isn't supported by this method, the error must be thrown in compile time. We've been trying to do this using static_cast but we are not obtaining the required results as the conversion between the two child classes is always possible.
class A{
...
};
class B : public A{
...
};
class C : public A{
...
}
void foo(A a){
if(a is B){
//OK and do stuff
}else if(a is C){
//throw compile error
}
}