   How to create a list of unknown pointer types?
  Hi.Recently I decided to take up C++ once again to improve my OOP. Everything has been rather smooth sailing until now. My problem is that I have this C++ list (called listeners) which should store pointers to different types of classes. The idea is that I will under certain circumstances go through the list and use the pointers and call a certain function (update()) in all classes they point to.The problem here is when I create a list, I need to specify the type for the list! I don't really know which type to use, after all I want pointers to different kind of classes to be stored.I hope you understand my problem here and hopefully this is just some minor thing that have slipped by me :).Thank you for any assistance./Puuff   
  Use an abstract base class that declares the update() method, and derive your "different types of classes" from that. Then you can effectively handle the derived class instances as list of base class instances in a type safe way. This paradigm is called "polymorphism". It is very useful in all modern object-oriented languages.   ;  Hi,The easiest way would be to have an abstarct base class as an update interface.class Updateable{    public:   virtual void Update(void) = 0;};All classes that need to have an update function should derive from this class and implement the update function.You would then have a list of Updateable classes which you could loop through and call the virtual update function.Another way would be to use void pointers but this would require you to know which class the void pointer is pointing to so I would recommend aginst this method.   ;  Thank you guys for helping me, just what I needed :).EDIT: I guess I was a litle quick and failed to test the solution extensively. As soon as I let my class Model inherit from the abstract class UpdateAble I get the following linker errors:model.o: In function `Model::~Model()':model.cpp:(.text+0x3): undefined reference to `vtable for Model'model.o: In function `Model::~Model()':model.cpp:(.text+0x13): undefined reference to `vtable for Model'model.o: In function `Model::Model()':model.cpp:(.text+0x4c): undefined reference to `vtable for Model'model.o: In function `Model::Model()':model.cpp:(.text+0x6c): undefined reference to `vtable for Model'collect2: ld returned 1 exit statusMy abstract class looks like this:class UpdateAble{public:UpdateAble();virtual void update(string message) = 0;};And in my Model class I implement the void update (which it inherits from the UpdateAble class) function (though I do not declare it, I assume that's not needed?).NOTE! If I do remove the update-function from the Model class and don't inherit from the UpdateAble class I get no errors!Hopefully you can help me understand what I'm doing wrong here.[Edited by - puuff on April 18, 2010 4:36:48 AM];  You have to declare the update function in your Model-class:class Model : public UpdateAble{   public: void update(string message);  // ...};;  I'm guessing that you don't have implementations of Model::Model() and Model::~Model() defined.If this is the case, you can either implement them (to introduce Model-specific functionality) or remove them from the declaration of the Model class (in which case the base class implementations are used).   ;  Another important detail is that your base class should have a virtual destructor.   