for this kind of thing you really want either a boost.ptr_vector or a container or boost.shared_ptr's.
your code would look something like
Code:
class Weapon
{
virtual void Strike(void) = 0;
};
class Sword : public Weapon {};
class Staff : public Weapon {};
class Bow : public Weapon {};
class ThermoNuclearWarhead : public Weapon {};
boost::ptr_vector<Weapon> m_weapons;
m_weapons.push_back(new Sword);
m_weapons.push_back(new Staff);
m_weapons.push_back(new Bow);
m_weapons.push_back(new ThermoNuclearWarhead);
then you can use boost.bind to do even cooler stuff like
Code:
// call Strike() on each weapon polymorphically...
std::for_each(m_weapons.begin(), m_weapons.end(),
boost::bind(&Weapon::Strike, _1);
and that is the power of C++, mixing functional and OO techniques.
edit: fixed code tags