You need to declare the class in C ++ / CLI as ref class.
(Note that we are talking about C ++ / CLI, not C ++. I assume that you must include the CLR in your C ++ project or you cannot get the new one CFooto work.)
Edit:
ref.
, ++:
class FooUnmanaged
{
int x;
FooUnmanaged() : x(5) {}
};
CLR:
ref class FooManaged
{
FooUnmanaged m;
};
, , . :
ref class FooManaged
{
FooUnmanaged *m;
};
. , , , System.IntPtr .
, , delete. :
ref class FooManaged
{
FooUnmanaged *u;
public:
FooManaged(FooUnmanaged *u_)
: u(u_) { }
~FooManaged() { delete u; }
};
, ++. , ++/CLI .
, IL , FooManaged IDisposable, Dispose. .NET- , . #
using (var m = new FooManaged())
{
}