title: how to return C++ pointer in objective-C++
body: <p>I have the following objective-C++ header with the simple method to return this pointer.</p>
  
  <pre><code>@interface MyObj
  {
    MyCPPObj * cpp;
  }
  -(MyCPPObj *) getObj;
  </code></pre>
  
  <p>I have created the simple method</p>
  
  <pre><code>@implementation MyObj
  -(MyCPPObj *) getObj
  {
    return cpp;
  }
  </code></pre>
  
  <p>Everything seems to work until I actually try to use the object in another file</p>
  
  <pre><code>newObj = [createdMyObj getObj];
  </code></pre>
  
  <p>It complains: error: cannot convert 'objc_object*' to 'MyCPPObje *' in initialization.</p>
  
  <p>It seems that the method is return an objective-c object, but I specifically requested a C++ pointer. </p>
  
  <p>MyCPPObj is an honest C++ class:</p>
  
  <pre><code>class MyCPPObj
  {
   public:
     int x;
  }
  </code></pre>
  
  <p>How can I fix that?</p>