Using a C++ class in C#
<p>How can I use a C++ class in C#? I know you can use DllImport and have the class as IntPtr, but then how would I call the functions inside the class? And I don't want to create a new method for each method in the class and export that, then there is not point for me to use a class then...</p>

<p><strong>Without creating a COM app</strong></p>

<p>C++ Class:</p>

<pre><code>class MyCPPClass 
{
public:
  MyCPPClass();
  ~MyCPPClass();
  void call_me();
}

extern "C" 
{
  extern __declspec(dllexport) MyCPPClass* __cdecl CreateClass() 
  {
    return new MyCPPClass();
  }
}
</code></pre>

<p>C#:</p>

<pre><code>class MyCSClass
{
  [DllImport("MyCPPDll.dll")]
  static extern IntPtr CreateClass();

  public static void Main()
  {
    IntPtr cc = CreateClass();
    // Now I want to call cc-&gt;call_me();
  }
}
</code></pre>
