Author | Message | Time |
---|---|---|
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:[code]frmMain::AddDebug(szTextBuffer, Drawing::Color::Red);[/code]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. | September 1, 2006, 10:24 PM |
kamakazie | [quote author=Dyndrilliac link=topic=15613.msg157400#msg157400 date=1157149476] 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. [/quote] You create an instance of that class and call the member method. [quote author=Dyndrilliac link=topic=15613.msg157400#msg157400 date=1157149476] I got the error on this code:[code]frmMain::AddDebug(szTextBuffer, Drawing::Color::Red);[/code]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] 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. | September 2, 2006, 12:45 AM |
Myndfyr | 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. | September 5, 2006, 10:13 PM |