Managed C++, passing arguments by reference
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:
public ref class Window1 : public System::Windows::Forms::Form
And now, how to pass reference to var to some Window2 method or constructor?
When I'm doing it this way:
I'm getting this error
Window1->Window2->someMethod( var );
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).
An object from the gc heap (member of a managed class) cannot be converted to a native reference
(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.)