我试图查看是否有可能将用C#代码创建的C ++ / CLI对象解析为C#中另一个C ++ / CLI对象的构造函数。
为简化我的问题,我有2个C ++ / CLI类A和B。
CLI.h(C ++ / CLI包装类A和B的标头)
namespace Example {
public ref class A {
public:
A();
~A();
....
};
public ref class B {
public:
B(A a);
~B();
...
};
}
Form1.cs
private void Form1_Load(object sender, EventArgs e) {
Example.A a = new Example.A();
// A does some computation and updates the member variables
// i.e (std::vector) of its native class
// The reason why I need B to take in A as constructor is ` .
// because i need to access the member variables of the native
// A class when the computation of A completes.
Example.B b = new Example.B(a) // C# gives me Example.B(?) not supported by the language
有什么方法可以使CLI / C ++对象在C#中相互通信?
我一般来说对C ++ / CLI和C编程还是比较陌生的。 如果无法进行这种交流,我正在考虑将A和B的方法和变量完全合并到一个类中,以便可以访问成员变量。
非常感谢您!