Hello there. I would like some opinions and advice on a problem I’m tackling:
There’s a ParentClass defined in C++, which has some virtual functions such as Func1. Then I have ChildClassA and ChildClassB implemented also in C++, both of which override the Func1 in their own way.
MyPawn then has a variable called MySelectedElement of type ParentClass, and when certain button is pressed, it should call Func1 on MySelectedElement.
However, and here is where I hit a brick wall: As the variable is of type ParentClass, the function that gets called is not the overriden one but the base function.
I think this can be solved by trying to cast MySelectedElement to each of the Child classes, but that looks clumsy and inefficient.
Is there a better way to do it?
Thanks in advance