gpt4 book ai didi

c++ - 错误 : expected unqualified-id before 'friend'

转载 作者:行者123 更新时间:2023-11-30 03:05:26 25 4
gpt4 key购买 nike

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

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

这是我用 C++ 编写的一个小国际象棋程序的一部分

但是,当我编译时,出现以下错误:

expected unqualified-id before 'friend'

expected initializer before 'friend'

语法错误吗?

最佳答案

friend 是 C++ 中的关键字,允许私有(private)成员访问外部对象或函数的关键字。您不能使用 friend 作为标识符;以其他方式命名(可能是 friend_)。

关于c++ - 错误 : expected unqualified-id before 'friend' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7719808/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com