Hi there,
To quickly ilustrate my problem, say I got a ref class that's creating a window, with some variable as well as handle to second window which should modify mentioned variable, eg:
Code:
public ref class Window1 : public System::Windows::Forms::Form
{
private:
int var;
Window2^ win;
// ...
}
;
And now, how to pass reference to var to some Window2 method or constructor?
When I'm doing it this way:
Code:
Window2::someMethod(int& ref);
Window1->Window2->someMethod( var );
I'm getting this error
Code:
An object from the gc heap (member of a managed class) cannot be converted to a native reference
The error message itself explains what's going on quite much, but for some reasons I couldn't find answer how to solve it (or maybe I got it all wrong).
(I know I could use ->get() method as for single variable, but in real program I'm using more variables, that's why I thought references might come in handy... Maybe I should wrap them in some class and try to work with passing pointers? But still, how to do it using references is what's bugging me.)