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. Advertisements

  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. Advertisements

  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. Advertisements

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:
    757
    Rolf Magnus
    Jul 25, 2003
  2. BlueTrin
    Replies:
    6
    Views:
    3,962
    BlueTrin
    Apr 5, 2006
  3. =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?=

    Help on table align on left of page vs left hanging indent

    =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?=, Jul 10, 2007, in forum: XML
    Replies:
    2
    Views:
    1,281
    =?iso-8859-1?q?Jean-Fran=E7ois_Michaud?=
    Jul 16, 2007
  4. s88
    Replies:
    3
    Views:
    1,582
    Jim Langston
    Sep 23, 2010
  5. Prasoon Saurav
    Replies:
    1
    Views:
    669
  6. pc
    Replies:
    2
    Views:
    1,625
    crisgoogle
    Jun 8, 2011
  7. lawrence
    Replies:
    13
    Views:
    544
    Thomas 'PointedEars' Lahn
    Sep 4, 2004
  8. Victor Hooi
    Replies:
    4
    Views:
    515
Loading...