Derive your objects from this class and implement doSomething():
class Element
{
public:
Element();
~Element();
virtual void doSomething()=0;
Element* next;
static void addElement( Element* el )
{
el->next = first;
first = el;
}
static Element* first=nullptr;
};
And to use it:
// Adding one element to the list:
Element::addElement( &myObject );
// Iterating over the objects:
Element* el = Element::first;
while( el )
{
el->doSomething();
el = el->next;
}