title: Using an Objective-C++ class with C++ instance variables in Objective-C code
body: <p>I'm writing an Objective-C++ class interface that has to be usable from both Objective-C and Objective-C++. The problem is that, because it must be usable from Objective-C, I cannot simply use a C++ type. I want to do it using pointers and I came up with this:</p>
  
  <pre><code>@interface SXDiff : NSObject {
  @private
  #ifdef __cplusplus
    dtl::Diff&lt;std::string, std::vector&lt;std::string&gt; &gt; *_diff;
  #else
    void *_diff;
  #endif
  }
  
  ...
  
  @end
  </code></pre>
  
  <p>Can any problems occur when doing this? Is there a better way of doing this?</p>
  
  <hr>
  
  <p>Note that the use of pointers is just to get the size of the ivar to be the same in both Objective-C and Objective-C++. The ivar can only be used from within the class implementation of <code>SXDiff</code> (it's <code>@private</code>). The implementation is written in Objective-C++.</p>