"illegal operand" error

K

Kostatus

The following code worked perfectly fine until i modified an unrelated part
of the program:
this->dungArea[x][y].mBlocked =
mioS.mio_dungArea[x][y].mFlags & isBlocked;

after that i started getting the error message:
error C2297: '&' : illegal, right operand has type 'bool (__thiscall
cDungeon::*)(int,int)'


Also,
if(this->dungArea[x][y].mBlocked)
mioS.mio_dungArea[x][y].mFlags |= isBlocked;

stopped working with the same kind of error message:
error C2297: '|=' : illegal, right operand has type 'bool (__thiscall
cDungeon::*)(int,int)'

Can anyone help me fix this?
 
J

John Carson

Kostatus said:
The following code worked perfectly fine until i modified an
unrelated part of the program:
this->dungArea[x][y].mBlocked =
mioS.mio_dungArea[x][y].mFlags & isBlocked;

after that i started getting the error message:
error C2297: '&' : illegal, right operand has type 'bool
(__thiscall cDungeon::*)(int,int)'


Also,
if(this->dungArea[x][y].mBlocked)
mioS.mio_dungArea[x][y].mFlags |= isBlocked;

stopped working with the same kind of error message:
error C2297: '|=' : illegal, right operand has type 'bool
(__thiscall cDungeon::*)(int,int)'

Can anyone help me fix this?


Looks to me like isBlocked has been defined to be a pointer to a member
function of class cDungeon. Evidently, you can't use such pointers in
conjunction with the & operator.
 
R

Rolf Magnus

Kostatus said:
The following code worked perfectly fine until i modified an unrelated
part of the program:
this->dungArea[x][y].mBlocked =
mioS.mio_dungArea[x][y].mFlags & isBlocked;

after that i started getting the error message:
error C2297: '&' : illegal, right operand has type 'bool
(__thiscall
cDungeon::*)(int,int)'

Looks to me like isBlocked is not a variable, but a function, so the
compiler converts it into a pointer to it and gives it to the
operator&. Maybe you wanted to call the function instead? So you
probably wanted:

this->dungArea[x][y].mBlocked =
mioS.mio_dungArea[x][y].mFlags & isBlocked();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top