包装到c ++ / cli

时间:2011-02-13 18:11:19

标签: c++-cli wrapper

c ++ / cli包装器的基本结构是什么,所以可以从c#中调用它?

1 个答案:

答案 0 :(得分:2)

C ++类Blah的包装器:

修改

ref class BlahWrapper {
  BlahWrapper () {
     blah = new Blah();
  }

  !BlahWrapper() { //Destructor called by GC
     if (blah != null) {
         delete blah;
         blah = null;
     }
  }

  ~BlahWrapper() { //Dispose() called in "using" blocks,  or manually dispose
     if (blah != null) {
         delete blah;
         blah = null;
     }
  }

  private:
  Blah* blah;
}