I'm trying to override Object::Equals in C++ .NET but I'm running into some difficulties
virtual bool IState::Equals(Object^ o) override{
if (o->GetType() == IState::typeid){
IState^ s = (IState^) o;
if (s->type == this->type &&
s->target_state == this->target_state &&
s->current_state == this->current_state){
return true;
}
else{
return false;
}
}
return false;
}
This code works fine if o is and IState. However, I inherit from IState with State. I'd like my Equals function to return true if I pass a State with the same content.
I get that State is not the same as IState, but is there an operator which will allow me to check if they inherit from the same base class? Maybe overloading the operator typeid might help, but it seems like a lot of trouble for that