编译器错误 C2626
“标识符”: 匿名结构或联合中不允许使用私有或受保护的数据成员
匿名结构或联合的成员必须具有公共访问。
以下示例生成 C2626:
// C2626.cpp
int main() {
union {
protected:
int j; // C2626, j is protected
private:
int k; // C2626, k is private
};
}
若要解决此问题,请移除任何私有或受保护的标记:
// C2626b.cpp
int main() {
union {
public:
int i; // OK, i is public
};
}