Linked list of different classes - in a maintanable way?
<p>Yo people,</p>

<p>My problem is, I have to find a way to easily maintain the next situation:
I have a linked list of different classes. I use void pointers, every class has "int type" as its first member.</p>

<p>Now when I want to call a class member function, I have to do this:
- Read the int, so I know the type of the class.
- I call a generic function with the type information, and also the "function" information to know which class member function to call.</p>

<p>So its basically a switch case in a switch case like this:</p>

<pre><code>void command(void *&amp;pointer, int type, int function)
   {
   switch (type)
      {
      case 1:
      switch (function)
         {
         case 1:
         reinterpret_cast&lt;myClass *&gt;(pointer)-&gt;doSomething();
         }
      }

   }
</code></pre>

<p>I do not even know what to do when a function, like "doSomething()" will need some arguments.</p>

<p>And it is a total mess anyway. I am sure there is a better way than this, but do not know what is it.</p>

<p>Anyone care to enlighten me?</p>
