【发布时间】:2021-12-28 09:20:17
【问题描述】:
我尝试通过以下方式在 C++ 中定义结构类型:
struct fckxMsg_t {
unsigned char : status;
unsigned char : data1;
unsigned char : data2;
};
我的编译器抱怨:
error: 'status' was not declared in this scope unsigned char : status;
我看不出有什么问题。其实我只是想给成员一个名字。为什么之前要声明???
【问题讨论】:
-
变量声明中没有冒号
-
你想做什么?只定义那些结构成员?
-
糟糕,我看到定义的第一部分不在我的帖子中。内容为:struct myStruct{
-
好的,我明白了。它是定义中的冒号.....谢谢!
-
我怀疑您将 C++ 与其他语言混淆了,并且会从 a good book 中受益。