Is there a way to determine the type of a child class with a baseclass pointer?
I have declared a pointer in a class constructor like this in .h file
baseclass *screen;
in constructor
screen = new childclass();
Lets say baseclass has 5 different child classes and in my program I switch my pointer around to point towards various child objects, how can I determine the type of the object that screen is currently pointing towards?
Don't.
Use virtual dispatch to achieve different behaviours for different derived types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With