C++ Calling a function that resides in multiple clases
<pre><code>#define classAnum 2;
#define classBnum 3;

class Base
{
  virtual int open()=0;
  virtual int close()=0;
}
class A:public Base
{
 virtual int open();
 virtual int close();
};

class B:public Base
{
 virtual int open();
 virtual int close();
}

int main()
{
    A classA[classAnum];
    B classB[classBnum];

openAnyClass(1);
CloseAnyClass(2);   
}
</code></pre>

<p>I want to achieve functionality like this.</p>

<pre><code>openAnyClass(1);
CloseAnyClass(2); 
</code></pre>

<p>these 2 functions should be able to call open() and close() from any of class A and B.</p>

<p>openAnyClass(1) would call the open() function of 1st object in the array of either classA or classB.</p>

<p>open() --> will have different implementation in class A and class B. and open() in classA may be cladded from multiple clients and max. no. of clients is # defined.</p>

<p>At a time only one open() from any of the classA or classB is called. I dont want to have several copies of the same code.</p>

<p>with just one fucntion i want call open() of any of class A and any of client. </p>

<p>for Eg: in the below statement i want to call open() of class A of client1. the param to openAnyClass(int) indicates the client Id. This could also meant <code>classB[1].open();</code></p>

<pre><code>'openAnyClass(1) = classA[1].open();'
</code></pre>

<p>What is the best way of doing this?</p>
