error: expected unqualified-id before 'friend'
struct side { /* Attacks */
byte attack[64];
int 开发者_Go百科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?
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_
).
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.
friend
is a keyword in C++. You may not use it as a variable name.
friend
is a reserved keyword in c++; name it something else.
For more info about what friend
is used for, see here.
Naturally. friend is one of many reserved keywords in c++. Just change the name
精彩评论