![]() |
Another Curious C++ Error - Illegal Left Operand
You guys were so great with answering my first question that I've decided to
ask you yet again! Again, only the relevant code is included. typedef unsigned int unint; #include <iostream> class Creature { public: unint ReturnSpellPoints() {return crSpellPoints;} void SetSpellPoints(int points) {crSpellPoints = points;} private: unint crSpellPoints; }; int main() { Creature *Play1 = new Creature; Play1->SetSpellPoints(10); if (Play1->ReturnSpellPoints > 0) //Line 17 std::cout << "Select an action:\n"; return 0; } -- C:\...filename(17) : error C2296: '>' : illegal, left operand has type 'unsigned int (__thiscall Creature::*)(void)' -- What's wrong with the operand? And what's __thiscall? Thanks, Tim M. |
Re: Another Curious C++ Error - Illegal Left Operand
> class Creature
> { > public: > unint ReturnSpellPoints() {return crSpellPoints;} [...] > }; > > int main() > { [...] > if (Play1->ReturnSpellPoints > 0) //Line 17 [...] > } while ReturnSpellPoints() is a function, you should call a function ;-) if (Play1->ReturnSpellPoints() > 0) //Line 17, regard the brackets Patrick |
Re: Another Curious C++ Error - Illegal Left Operand
"Thomas Matthews" <thomas_matthews@sbcglobal.net> wrote in message news:3EFA0A95.2060201@sbcglobal.net... > The expression "Play1->ReturnSpellPoints" is the value or > address of the method. To envoke the function you need the "()". Well actually, it's just invalid. It doesn't form a pointer to member either. |
| All times are GMT. The time now is 10:30 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.