Results 1 to 6 of 6

Thread: C++ error...hlp

  1. #1
    Join Date
    Oct 2009
    Posts
    7

    C++ error...hlp

    syntax error : missing ',' before 'constant'

    I am receiving this error.
    It refers to the Character(DrawEngine etc... line of code but I can not find a "missing" ','

    I am following the C++ tutorials using Microsoft visual studio 2008.


    Code:
    #ifndef CHARACTER_H
    #define CHARACTER_H
    
    #include "sprite.h"
    
    class Character : public Sprite
    {
    public:
    	Character(DrawEngine *de, int s_index, float x = 1, float y = 1, int lives = 3, char up_key = 'w', char down_key = 's', char left_key 'a', char right_key = 'd');
    
    	virtual bool keyPress(char c);
    
    protected:
    	char upKey;
    	char downKey;
    	char leftKey;
    	char rightKey;
    };
    
    #endif
    Any help is very much appreciated.

  2. #2
    Join Date
    Oct 2009
    Location
    The In Between. US
    Posts
    2,030
    I think it might be because it doesn't know what DrawEngine is so it is assuming DrawEngine is another variable. It needs to now about it some how

  3. #3
    Join Date
    Mar 2006
    Location
    South Australia
    Posts
    4,521
    My guess is you also need to #include "DrawEngine.h"

    However, in the future it is a lot easier to figure out things if you paste the exact compiler output.

  4. #4
    Join Date
    Oct 2006
    Location
    Melbourne
    Posts
    743
    I think you'll find the problem to be here:

    char left_key 'a'

    Shouldn't there be an assignment operator between left_key and 'a'?

  5. #5
    Join Date
    Oct 2009
    Posts
    7
    Quote Originally Posted by enhzflep View Post
    I think you'll find the problem to be here:

    char left_key 'a'

    Shouldn't there be an assignment operator between left_key and 'a'?
    SOB....

    That fixed it....thanks man....

    I must have looked over that line of code for like 30 mins....just couldnt see the problem....

    Thanks Again!!!

  6. #6
    Join Date
    Mar 2004
    Posts
    0
    Quote Originally Posted by enhzflep View Post
    I think you'll find the problem to be here:

    char left_key 'a'

    Shouldn't there be an assignment operator between left_key and 'a'?
    Haha, nice find dude... I was about to post saying that I can't find anything wrong with that file

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •