Hi, I understand the basic concepts of polymorphism but the tutorials that I have read don't seem to mention a bit of information I need.
Say I have a base class:
class Player
{
public:
Player();
~Player();
void displayPlayer(); //Display the player
};
Then a derived class:
class Attacker : public Player
{
public:
Attacker();
~Attacker();
void checkPositionType();
};
When I create a new Attacker using a player pointer a la:
Player* attacker = new Attacker
I can call all the methods in the base class thus:
attacker->displayPlayer();
but I can't call the methods that are only in the derived class:
attacker->checkPositionType();
Now I beleive I can get around this by putting the 'checkPositionType()' function that is in the derived Attacker class in the base Player class as a virtual function so that it gets overwritten but is there a way I can avoid doing this and only have the function in the derived class yet still call it using a Player pointer?