title: How can I use a 'native' pointer in a reference class in C++/CLI?
body: <p>I am trying to write a small library which will use DirectShow. This library is to be utilised by a .NET application so I thought it would be best to write it in C++/CLI.</p>
  
  <p>I am having trouble with this line however:</p>
  
  <pre><code>    HRESULT hr = CoCreateInstance(  CLSID_FilterGraph,
                                      NULL,
                                      CLSCTX_INPROC_SERVER,
                                      IID_IGraphBuilder,
                                      (void**)(&amp;graphBuilder) );  //error C2440:
  </code></pre>
  
  <p>Where <code>graphBuilder</code> is declared:</p>
  
  <pre><code>public ref class VideoPlayer
  {
  public:
      VideoPlayer();
      void Load(String^ filename);
  
      IGraphBuilder*  graphBuilder;
  
  };
  </code></pre>
  
  <p>If I am understanding <a href="http://manski.net/2011/04/19/cpp-cli-cheat-sheet/" rel="nofollow noreferrer">this page</a> correctly, I can use <code>*/&amp;</code> as usual to denote 'native' pointers to unmanaged memory in my C++/CLI library; <code>^</code> is used to denote a pointer to a managed object.  However, this code produces:</p>
  
  <blockquote>
    <p>error C2440: 'type cast' : cannot convert from 'cli::interior_ptr' to 'void **'</p>
  </blockquote>
  
  <p>The error suggests that <code>graphBuilder</code> is considered to be a <code>'cli::interior_ptr&lt;Type&gt;'</code>.  That is a pointer/handle to managed memory, isn't it?  But it is a pure native pointer.  I am not trying to pass the pointer to a method expecting a handle or vice versa - I simply want to store it in my managed class) If so, how do I say <code>graphBuilder</code> is to be a 'traditional' pointer?</p>
  
  <p>(<a href="https://stackoverflow.com/questions/1271022/convert-from-c-cli-pointer-to-native-c-pointer">This question</a> is similar but the answer, to use a pin_ptr, I do not see helping me, as it cannot be a member of my class)</p>