By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,389 Members | 2,052 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,389 IT Pros & Developers. It's quick & easy.

Another Curious C++ Error - Illegal Left Operand

P: n/a
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.
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
> 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
Jul 19 '05 #2

P: n/a

"Thomas Matthews" <th*************@sbcglobal.net> wrote in message news:3E**************@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.

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.