I have a general class Player and inside the class I declare an object of a smaller class, for example, Weapon, Inventory etc.
Naturally I have use pointers (shared_ptr) to instantiate my Player objects and used the same method to instantiate any object withing my class. Should I keep on doing this or should I try to make it more simple by not using pointers and will this come with a certain disadvantage?
class Player: public Human, public Control
{
public:
Player();
~Player(){};
private:
Weapon myWeapon;
std::vector<std::tr1::shared_ptr<Weapon> > WeaponsList;
};
vs.
class Player: public Human, public Control
{
public:
Player();
~Player(){};
private:
Weapon myWeapon;
std::vector<Weapon> WeaponsList;
};
Note, I use shared_ptr and want to keep an option to have Weapon to be a base class at some point (but no rush!).
Weapona polymorphic type?class Playerbe calledPlayer(), notgPlayer()? Why isMountWeapon()working onints butmyWeaponof typeWeapon? Why is the memberpublic? Why isrWeapon()returning a non-constreference to a member? Why is the use of pointers a "naturally"? Why isDraw()a member ofPlayer? Ohmagawd... :-D