user975900
user975900

Reputation: 77

error: expected unqualified-id before 'friend'

struct side {           /* Attacks */
    byte attack[64];
    int king;
    byte pawns[10];
};

   static struct side white, black, *friend, *enemy;

This is part of a small chess program I'm doing in C++

When I compile, however, I get the following errors:

expected unqualified-id before 'friend'

expected initializer before 'friend'

Is the syntax wrong?

Upvotes: 1

Views: 1356

Answers (5)

friendzis
friendzis

Reputation: 809

Naturally. friend is one of many reserved keywords in c++. Just change the name

Upvotes: 0

WildCrustacean
WildCrustacean

Reputation: 5966

friend is a reserved keyword in c++; name it something else.

For more info about what friend is used for, see here.

Upvotes: 0

Alexander Gessler
Alexander Gessler

Reputation: 46607

friend is a keyword in C++, so it cannot be used as variable name. SO's syntax highlighting makes this pretty obvious; all you can do is to pick another name.

Upvotes: 1

K-ballo
K-ballo

Reputation: 81349

friend is a keyword in C++, the keyword to allow access of private members to an external object or function. You cannot use friend as an identifier; name it some other way (perhaps friend_).

Upvotes: 2

Lightness Races in Orbit
Lightness Races in Orbit

Reputation: 385174

friend is a keyword in C++. You may not use it as a variable name.

Upvotes: 0

Related Questions