Lars_V_J
October 29th, 2009, 10:41 AM
if I have (managed c++)
namespace MyNS
{
class MyManagedClass
{
....
};
}
and then in my UNmanaged code:
class MyUnmanagedClass
{
void MyFunc();
}
void MyUnmanagedClass::MyFunc()
{
MyNS::MyManagedClass *p = new MyNS::MyManagedClass();
}
I get
error C3150: 'p' : '__gc' can only be applied to a class, struct, interface, array or pointer
error C3821: 'MyNS::MyManagedClass': managed type cannot be used in an unmanaged function
Is there a way around that? The only one I've seen is to declare the managed class static, and then use functions to call the static member functions. This is not good, as it only allows one instance of the class.
Thanks in advance.
namespace MyNS
{
class MyManagedClass
{
....
};
}
and then in my UNmanaged code:
class MyUnmanagedClass
{
void MyFunc();
}
void MyUnmanagedClass::MyFunc()
{
MyNS::MyManagedClass *p = new MyNS::MyManagedClass();
}
I get
error C3150: 'p' : '__gc' can only be applied to a class, struct, interface, array or pointer
error C3821: 'MyNS::MyManagedClass': managed type cannot be used in an unmanaged function
Is there a way around that? The only one I've seen is to declare the managed class static, and then use functions to call the static member functions. This is not good, as it only allows one instance of the class.
Thanks in advance.