"illegal operand" error

Discussion in 'C++' started by Kostatus, Jul 25, 2003.

  1. Kostatus

    Kostatus Guest

    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?
     
    Kostatus, Jul 25, 2003
    #1
    1. Advertising

  2. Kostatus

    John Carson Guest

    "Kostatus" <> wrote in message
    news:bfqlv8$9a8$
    > 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.
     
    John Carson, Jul 25, 2003
    #2
    1. Advertising

  3. Kostatus

    Rolf Magnus Guest

    Kostatus wrote:

    > 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();
     
    Rolf Magnus, Jul 25, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hfk0
    Replies:
    2
    Views:
    21,705
  2. JavaQueries
    Replies:
    1
    Views:
    3,709
    John C. Bollinger
    Mar 1, 2005
  3. Balaji
    Replies:
    3
    Views:
    10,140
  4. Bishop
    Replies:
    1
    Views:
    807
    Bishop
    Feb 24, 2007
  5. juvi
    Replies:
    3
    Views:
    1,063
    Alexey Smirnov
    Jan 22, 2009
Loading...

Share This Page