wrapper to c++/cli

坚强是说给别人听的谎言 提交于 2019-12-08 06:32:06

问题


What is the basic structure of a wrapper to c++/cli so it can be called from c# ?


回答1:


A wrapper for a C++ class Blah:

EDIT:

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;
}


来源:https://stackoverflow.com/questions/4985907/wrapper-to-c-cli

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!