Quantcast
Channel: C++: Array of parent and child objects - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by John3136 for C++: Array of parent and child objects

$
0
0

By "access special methods" I assume you mean methods in just the OpenPlayer or just the ClosedPlayer?

By array, I assume you mean some STL collection ;-)

The short answer is "No".

The long answer is "Yes you can, but you'll need to cast objects to the correct type. This implies that your design is wrong."

A different disign might be to make "Open" or "Closed" a property of the Player class rather than individual subclasses.


Viewing all articles
Browse latest Browse all 3

Trending Articles