Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Another Curious C++ Error - Illegal Left Operand (http://www.velocityreviews.com/forums/t267728-another-curious-c-error-illegal-left-operand.html)

Tim Mierzejewski 06-25-2003 08:24 PM

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.



Patrick Kowalzick 06-25-2003 08:45 PM

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



Ron Natalie 06-25-2003 09:37 PM

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 08:51 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.