最好封装成dll、ActiveX、Atl等再调用#using <mscorlib.dll> #include <vcclr.h> using namespace System; class CppClass { public: gcroot<String*> str; // can use str as if it were String* CppClass() {} }; int main() { CppClass c; c.str = new String("hello"); Console::WriteLine( c.str ); // no cast required } Output
#include <vcclr.h>
using namespace System; class CppClass {
public:
gcroot<String*> str; // can use str as if it were String*
CppClass() {}
}; int main() {
CppClass c;
c.str = new String("hello");
Console::WriteLine( c.str ); // no cast required
}
Output
C#的DLL只能是vc7,VB。NET,C#可以用,c++用不了如果用WEB SERVICE也可以,不过c++调用会比较麻烦,但不需要。NET框架