visual-studio - c#怎么调用c++的类和函数
PHPz
PHPz 2017-04-17 14:21:50
0
2
449
PHPz
PHPz

学习是最好的投资!

全部回复(2)
PHPzhong

一种方式是托管 c++,但是有可能对代码更改较大,
另一种是链接

迷茫

check out C++/CLI (aka managed C++). Write a wrapper that uses your native class as a member

最好给每一个用到的native concrete class 写一个对应的Interface,在Managed C++ 里用 INativeCore 而不是NativeCore ,来避免一些坑

// in your native core:

// define an interface wrapper for your native core
class INativeCore{
// ...
}
class NativeCore: public INativeCore{
// ... 
}

// in your C++/CLI code
ref public class ManagedClass{
private:
  INativeCore* pCore; // delegate all method calls to native core
public:
  void foo(){
  pCore->foo(); 
}
// ... other methods
}

equivalent SO question

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!