Another Curious C++ Error - Illegal Left Operand

Discussion in 'C++' started by Tim Mierzejewski, Jun 25, 2003.

  1. 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.
    Tim Mierzejewski, Jun 25, 2003
    #1
    1. Advertising

  2. > 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
    Patrick Kowalzick, Jun 25, 2003
    #2
    1. Advertising

  3. Tim Mierzejewski

    Ron Natalie Guest

    "Thomas Matthews" <> wrote in message news:...

    > 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.
    Ron Natalie, Jun 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. Kostatus

    "illegal operand" error

    Kostatus, Jul 25, 2003, in forum: C++
    Replies:
    2
    Views:
    628
    Rolf Magnus
    Jul 25, 2003
  2. BlueTrin
    Replies:
    6
    Views:
    3,633
    BlueTrin
    Apr 5, 2006
  3. s88
    Replies:
    3
    Views:
    1,053
    Jim Langston
    Sep 23, 2010
  4. Prasoon Saurav
    Replies:
    1
    Views:
    509
  5. pc
    Replies:
    2
    Views:
    1,312
    crisgoogle
    Jun 8, 2011
Loading...

Share This Page