473,395 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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.
Jul 19 '05 #1
2 4396
> 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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kostatus | last post by:
The following code worked perfectly fine until i modified an unrelated part of the program: this->dungArea.mBlocked = mioS.mio_dungArea.mFlags & isBlocked; after that i started getting the...
6
by: c++newbie | last post by:
Hi all, I try to compile the following classes: main.cpp: #include <algorithm> #include <iostream> #include <fstream> #include <iterator>
6
by: BlueTrin | last post by:
Hello I was adapting a C version of SolvOpt in C++ to use it within a virtual class. However I am stuck with the overriding of evaluation and gradiant functions. cStepCurveEvaluator.cpp...
2
by: linq936 | last post by:
Hi, I have this piece code, struct TriStr { MyString str1; MyString str2; MyString str3; TriStr(MyString s1, MyString s2, MyString s3){ this->str1 = s1;
29
by: aarthi28 | last post by:
Hi, I have written this code, and at the end, I am trying to write a vector of strings into a text file. However, my program is nor compiling, and it gives me the following error when I try to...
17
by: somenath | last post by:
Hi ALL, I have one doubt regarding the compilation error for the bellow mentioned code. #include<stdio.h> int main(void) { int a =5,b=0; a>5?b=3:b=5;
25
by: notahipee | last post by:
I have been trying to cin an number from 0 to 9 with a leading 0. For example 00 or 07. I was using a switch case. switch (int) { case 01: break; case 02: break;..... My problem arises at 08...
11
by: markryde | last post by:
Hello, Followed here is a simplified code example of something which I try to implement; in essence , I want to assign a value to a return value of a method is C. I know, of course, that in this...
3
by: charmeda103 | last post by:
I keep getting errors and i looked relooked I cant seem to see what wrong. from my code can see u where the errors are coming from. here are the error messages: 1.warning C4101: 'size' :...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.