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
}
一種方式是託管 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 ,來避免一些坑
equivalent SO question