Yes, and this is the start of your interface to your Toy classes. As I hinted at earlier, I would have one of the parameters being a pointer to the Toy Base class. See below for a different way of doing things with the CActor class.
The idea of the interface is to have a whole inheritance tree with a set of general functions that have consistent calling parameters to deal with all of the classes.
As to whether a function should be pure virtual or not, depends on what is being done. You should use pure virtual functions for the interface, but then you might have a branch of the inheritance tree that has a behaviour that is specific to that branch. So you could have an ordinary virtual function if there is still more specialisation, or just an ordinary function if their behaviour is the same.
For example, say you have a Room which consists of a 2d array of Tiles. You could have an ordinary virtual function called Move in the Toy class which is defined once and inherited through the whole tree, because it is the same no matter what object is being moved.
1 2 3 4
|
virtual void CToy::Move(CToy *TheToy, CTile * TheTile) { // C means class
//Your code here
}
|
I would think about what you mean exactly by the Play function - always think about about what the object is capable of doing. Instead of just the Play function, you could have various functions such as Move, Acquire (some resource such as gold or a weapon that lying around), Attack, Place (something a bomb say). Each of these functions could be put in the base class (CActor shown below) and be virtual - not necessarily pure - you may want to leave the behaviour to be inherited.
I would also consider having classes declarations like this:
1 2 3 4 5 6 7 8
|
class CActor ; //put common function in here
class CPlayer : public CActor ; // Players are on our side
class CEnemy : public CActor ;
class CWeapon {};
class CSword : public CWeapon ;
class CGun : public CWeapon;
|
These classes can be extended to cover all sorts of different things.
There is an even more complex way of doing these things which involves using the Mediator Design pattern (Google that if interested)- I am working on this at the moment.
I hope this has given you a bit to think about - and plenty to go on with. Have fun :D !!!!