c# - How to use managed variable as global in Visual C++? -


i'm writing mfc application in visual c++ , using 1 c# lib. dou combine unmanaged , managed classes , variables. need managed classes c# put , read to/from global scope accessible whole app. tried (simple example):

app.h:     class myclass1 {         public:             gcroot<namespace::something^> var;         };      class myclass2 {         public:             static gcroot<namespace::something^> var;         };      extern myclass1 *cl1;  app.cpp     myclass1 *cl1 = new myclass1(); 

when use "cl1->var", system.nullreferenceexception, myclass2 return error

error lnk2020: unresolved token (0a0003be) "public: static struct gcroot ... error lnk2001: unresolved external symbol "public: static struct gcroot ... 

please me, how use "something^ var" in whole app?

as other c++ static member, need define in addition declaring it. in app.cpp @ namespace scope, need:

gcroot<namespace::something^> myclass2::var; 

Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -