title: Multiple Interfaces to a Class in C++
body: <p>I have three classes that interact as follows. <code>Class A</code> contains a private member of type <code>Class B</code>. It also contains a method to which an object of type <code>ClassC</code> is passed. This method then calls a method on <code>ClassC</code>, passing to it a particular interface (<code>ClassBInterface1</code>) of its member of type <code>ClassB</code>:</p>
  
  <pre><code> ClassA
   {
       void Foo(ClassC ObjectC)
       {
           ObjectC.Bar((ClassBInterface1) ObjectB);
       }
       ClassB ObjectB;
   }
  </code></pre>
  
  <p>My question is: <code>ClassA</code> does not need to access the methods of <code>ClassB</code> defined in <code>Interface1</code>. Therefore, in my view, it would be more elegant if the member of <code>ClassA</code> was of type <code>ClassBInterface2</code>, rather than <code>ClassB</code>. Is it possible to do this, while still passing B to C under <code>Interface1</code>? </p>
  
  <p>The only way I can think of is to typecast <code>ClassBInterface2</code> to <code>ClassB</code> and back to <code>ClassBInterface1</code> in the Bar method in <code>ClassA</code>. </p>
  
  <p>Is this the best way to do it? Or should I just leave it as it is?</p>
  
  <p>Thanks a lot for any help.</p>