• Welcome to Valhalla Legends Archive.
 

[C++/CLI] Compiler Error C2352

Started by Dyndrilliac, September 01, 2006, 05:24 PM

Previous topic - Next topic

Dyndrilliac

MSDN defines C2352 as this: "A static member function called a nonstatic member function. Or, a nonstatic member function was called from outside the class as a static function."

Unfortunately, it doesn't mention how one would go about calling a non-static member method from outside the class as a non-static function. I got the error on this code:frmMain::AddDebug(szTextBuffer, Drawing::Color::Red);Can anyone clarify why the compiler thinks I am trying to call a static method, and what to do about it? Both class member-methods are non-static and public.
Quote from: Edsger W. DijkstraIt is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.

dxoigmn

Quote from: Dyndrilliac on September 01, 2006, 05:24 PM
Unfortunately, it doesn't mention how one would go about calling a non-static member method from outside the class as a non-static function.

You create an instance of that class and call the member method.

Quote from: Dyndrilliac on September 01, 2006, 05:24 PM
I got the error on this code:frmMain::AddDebug(szTextBuffer, Drawing::Color::Red);Can anyone clarify why the compiler thinks I am trying to call a static method, and what to do about it? Both class member-methods are non-static and public.

Going by what you're telling us, it sounds like frmMain is a class (not an instance of a class). You need to create an instance of frmMain, then call the method from that instance. You're also using the scope operator which, in this case, is used to call a static function.

MyndFyre

To add on to what dxoigmn said, you'll want to use the object dereference operator (myFrmMain->AddDebug()), or the dot operator (myFrmMain.AddDebug()), depending on whether your object is on the stack.  Most likely, you'll have a pointer, so you'll want to use the first.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.