   Using template instead of inheritance
  I need to make an UpdateManager simply call the Update method of a list of objects. I had done that using inheritance. The manager has a list of object that inherit from cUpdateable and by so have an Update method. But now I don't want to inherit from cUpdateable, because that will lead some objects to multiple inheritance which I want to avoid since I don't like the performance of dynamic_cast.I guess I saw a few years ago a paper describing how to use template to allow having a list of classes having a common method (e.g. void Update() ) with out using inheritance and then iterate the list and call the method. Like the followingclass A{  public:void Update();};class B{  public:   public void Update();};// Neither A or B inherit from other class, but both have the Update methodlist<algo*> lObjects;lObjects.push_back( new A );lObjects.push_back( new B );for (list<algo*>::iterator iter( lObjects.begin() ); iter != lObjects.end(); ++iter)    (*iter)->Update();Is that possible?   
  Yes, I believe it is possible and is sometimes known as 'static polymorphism'. You essentially describe it correctly but it has some limitations (and also some advantages) as compared to normal 'dynamic' polymorphism.I'm really no expert, but I believe the problem you will have in your case is that your templatised 'list' class holds *either* A's or B's but not both. Hence you would need two list. Is this ok for your situation?Unfortunatly I first read about this yesterday and so I'm probabl;y only recalling half the story...David   ;Quote:Original post by CaossTecIs that possible?Yes, but it's not *that* simple, unfortunately. C++ containers are homogeneous containers. You can store types that have a common base class using in a container of base pointers. But heterogeneous containers require significantly more work. Just throwing a template in won't be sufficient.You can have a look here for a potential solution, or you could just move your Update() function to a common base class.class IUpdate{public:   virtual void Update() = 0;   virtual void ~IUpdate() {}};class A : public IUpdate{public:   void Update() { /* ... */ }};class B : public IUpdate{public:   void Update() { /* ... */ }};list<IUpdate*> lObjects;lObjects.push_back( new A );lObjects.push_back( new B );list<IUpdate*>::iterator iter;for ( iter=  lObjects.begin(); iter != lObjects.end(); ++iter)    (*iter)->Update();