I have a managed class that has a member that is a pointer to native object. Like this (not a real code):
ref class ManagedClass {
private:
NativeClass* ptr = nullptr;
};
I need to initialize this pointer to point to a valid object by calling a native method, that takes pointer-to-pointer:
void native_init(NativeClass** nc);
But when I try to get this pointer-to-pointer for ptr by:
native_init(&ptr);
VS shows a message that
argument of type interion_ptr is incompatible with parameter of type NativeClass**
So, how can I get pointer to that pointer?
This code works:
NativeClass *local_ptr;
native_init(&local_ptr);
ptr = local_ptr;
But when I try to delete it like this:
delete ptr
The application crashes saying that I try to "to read or write protected memory". What should I do?