Heim > Fragen und Antworten > Hauptteil
迷茫2017-04-17 14:23:50
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