syntax

Discussion in 'C++' started by Michael Sgier, Sep 14, 2005.

  1. Hi
    what the heck is my syntax error here?
    THANKS and regards
    Michael
    PS: At what address is the FAQ located?

    world.h:65: error: syntax error before `;' token

    class CWorld
    {
    protected:
    void OnPrepare(CTerrain *terrain);

    public:
    void Prepare() { OnPrepare(CTerrain *terrain); } // here i get the
    //syntax error above
    };
    Michael Sgier, Sep 14, 2005
    #1
    1. Advertising

  2. Michael Sgier wrote:
    > Hi
    > what the heck is my syntax error here?
    > THANKS and regards
    > Michael
    > PS: At what address is the FAQ located?
    >
    > world.h:65: error: syntax error before `;' token
    >
    > class CWorld
    > {
    > protected:
    > void OnPrepare(CTerrain *terrain);
    >
    > public:
    > void Prepare() { OnPrepare(CTerrain *terrain); } // here i get the syntax error above


    void Prepare() { OnPrepare(terrain); }

    > };


    (IF CTerrain is poperly (forward) declared)

    /S.
    =?ISO-8859-1?Q?Stefan_N=E4we?=, Sep 14, 2005
    #2
    1. Advertising

  3. Michael Sgier wrote:
    >
    > Hi
    > what the heck is my syntax error here?
    > THANKS and regards
    > Michael
    > PS: At what address is the FAQ located?
    >
    > world.h:65: error: syntax error before `;' token
    >
    > class CWorld
    > {
    > protected:
    > void OnPrepare(CTerrain *terrain);
    >
    > public:
    > void Prepare() { OnPrepare(CTerrain *terrain); } // here i get the
    > //syntax error above


    When you call a function, you provide the arguments. Don't repeat the
    type of the arguments:

    A function:

    void foo( int a )
    {
    }

    and a call to it looks like this

    int main()
    {
    foo( 5 );
    int b = 8;
    foo( 8 );
    }

    but not

    int main()
    {
    foo( int a ); // this is *not* a call to a function
    // it looks a little bit like a function declaration if there
    // had been a return type specified.
    }

    > void Prepare() { OnPrepare(CTerrain *terrain); } // here i get the

    I guess you wanted:
    void Prepare() { OnPrepare(terrain); }

    But that leaves you with the question: where do I get terrain from.

    As for the FAQ:
    The FAQ doesn't help you very much at your stage. What you need is a good beginners
    book about C++. Most of your problems so far are of the very simple nature.
    The FAQ assumes that you know at least a little bit about what you are doing.

    --
    Karl Heinz Buchegger
    Karl Heinz Buchegger, Sep 14, 2005
    #3
  4. Michael Sgier

    Tim Love Guest

    Michael Sgier <> writes:


    >PS: At what address is the FAQ located?

    http://www.parashift.com/c -faq-lite/


    >class CWorld
    >{
    >protected:
    > void OnPrepare(CTerrain *terrain);


    >public:
    > void Prepare() { OnPrepare(CTerrain *terrain); } // here i get the
    > //syntax error above
    >};


    OnPrepare is a function elsewhere. Prepare is a function that calls
    OnPrepare, but when you call a routine you don't provide the arg types,
    just the args.
    Tim Love, Sep 14, 2005
    #4
    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. gabriele renzi
    Replies:
    2
    Views:
    200
    gabriele renzi
    Dec 31, 2005
  2. Ken Bloom
    Replies:
    3
    Views:
    203
  3. Good Night Moon
    Replies:
    9
    Views:
    275
    Rick DeNatale
    Jul 25, 2007
  4. Jacob Grover
    Replies:
    5
    Views:
    307
    Jacob Grover
    Jul 18, 2008
  5. Mark Richards
    Replies:
    3
    Views:
    308
    Tad McClellan
    Nov 18, 2007
Loading...

Share This Page