Here is my code:
class Soldier { public: Soldier(const string &name, const Gun &gun); string getName(); private: Gun gun; string name; }; cl
First off, you'd be violating the Law of Demeter by accessing the Gun from outside the Soldier class.
Gun
Soldier
I would consider methods like these instead:
soldier.ArmWeapon(...); soldier.Attack(...);
This way you could also implement your fist, knife, grenade, baseball bat, laser cat, etc.