Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCC - "expected unqualified-id before ')' token"

Tags:

c++

Please bear with me, I'm just learning C++.

I'm trying to write my header file (for class) and I'm running into an odd error.

cards.h:21: error: expected unqualified-id before ')' token
cards.h:22: error: expected `)' before "str"
cards.h:23: error: expected `)' before "r"

What does "expected unqualified-id before ')' token" mean? And what am I doing wrong?

Edit: Sorry, I didn't post the entire code.

/*
Card header file
[Author]
*/
// NOTE: Lanugage Docs here http://www.cplusplus.com/doc/tutorial/

#define Card
#define Hand
#define AppError

#include <string>

using namespace std;


// TODO: Docs here
class Card { // line 17
    public:
        enum Suit {Club, Diamond, Spade, Heart};
        enum Rank {Two, Three, Four, Five, Six, Seven, Eight, Nine,
                   Ten, Jack, Queen, King, Ace};
        Card(); // line 22
        Card(string str);
        Card(Rank r, Suit s);

Edit: I'm just trying to compile the header file by itself using "g++ file.h".

Edit: Closed question. My code is working now. Thanks everyone! Edit: Reopened question after reading Etiquette: Closing your posts

like image 267
epochwolf Avatar asked Sep 19 '08 22:09

epochwolf


People also ask

How do you fix expected unqualified ID before token?

– Adjust the Curly Braces To Fix the Expected Unqualified Id Error. You should match the opening and closing curly braces in your code to ensure the right quantity of brackets. The code should not have an extra or a missing curly bracket.

What is meant by unqualified ID in C++?

Something like class Test; // note the semicolon { }; in the global scope will give you unqualified id error before '{' since in the global scope a standalone {} makes no sense, but the samething works fine in local scope as it will be treated as an empty block scope.


1 Answers

Your issue is your #define. You did #define Card, so now everywhere Card is seen as a token, it will be replaced.

Usually a #define Token with no additional token, as in #define Token Replace will use the value 1.

Remove the #define Card, it's making line 22 read: 1(); or ();, which is causing the complaint.

like image 184
davenpcj Avatar answered Oct 29 '22 06:10

davenpcj