C++/CLI msvc++2010 class problem
I want to call the member function of a class created in my main f开发者_如何学JAVAunction, but I get some error, that I can't call a non-static member function. How to call the public member function "msg" of the "Form1"?
int main(array<System::String ^> ^args) {
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew Form1());
int test = 0;
if (test>0) {
Form1::msg("1");
} else {
Form1::msg("2");
}
return 0;
}
You need an instance handle of Form1
. Obviously you shall store the lvalue of gcnew Form1()
as the object to call msg
on.
精彩评论