title: Wrapper class in C++
body: <p>Say I have the following abstract class:</p>
  
  <pre><code>class AbstractClass {
    public:
      AbstractClass() {}
      virtual ~AbstractClass() {}
      virtual void virtMethod()
      {
         printf( "%p\n", this );
      }
      void method()
      {
        printf( "%p\n", this );
      }
      ...
  };
  </code></pre>
  
  <p>And the following child classes:</p>
  
  <pre><code>class RawClass : public AbstractClass
  {
    public:
      RawClass();
      ~RawClass();
      ...
  };
  
  class Wrapper : public AbstractClass
  {
    public:
      Wrapper( AbstractClass* wrapee ) : _wrappee ( wrappee ) {}
      ~Wrapper() {};
      void virtMethod()
      {
        _wrappee-&gt;virtMethod();
      }
      ...
  
    private:
      AbstractClass _wrappee;
  };
  </code></pre>
  
  <p>Now, say I do the following:</p>
  
  <pre><code>RawClass* r = new RawClass();
  Wrapper* w = new Wrapper( r );
  w-&gt;virtMethod(); // This prints the address of r
  w-&gt;method(); // This prints the address of w
  </code></pre>
  
  <p>What I would like to happen is for calls to <code>w-&gt;method()</code> to behave the same as calls to <code>w-&gt;virtMethod()</code>. However, I can't do this without making <code>method()</code> virtual and writing an implementation of it in <code>Wrapper</code> which merely calls <code>RawClass::method()</code>.</p>
  
  <p>I have clearly got some design issues here, but can't figure out a way to get this to work, whilst having <code>RawClass</code> and <code>Wrapper</code> prescribe to the same interface.</p>
  
  <p>Any help would be greatly appreciated.</p>