开发者

error: expected unqualified-id before 'friend'

开发者 https://www.devze.com 2023-04-11 21:27 出处:网络
struct side {/* Attacks */ byte attack[64]; int 开发者_Go百科king; byte pawns[10]; }; static struct side white, black, *friend, *enemy;
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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号