问题
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