问题描述
A级{
公开:
enum E {EN1,EN2,EN3};
};
B级{
public:
void f(const char * s,A :: E en = A :: E :: EN1);
};
MSVC 7.1接受它,G ++ 3.2.2(3.2.2-3mdk)给出以下错误:
`A :: E''不是聚合类型
这是G ++或VC中的错误吗?神圣标准说什么?
class A {
public:
enum E { EN1, EN2, EN3 };
};
class B {
public:
void f(const char *s, A::E en = A::E::EN1);
};
MSVC 7.1 accepts it, G++ 3.2.2 (3.2.2-3mdk) gives the following error:
`A::E'' is not an aggregate type
Is this an error in G++ or in VC? What does the Holy Standard say?
推荐答案
哎呀。错误是参考A :: E :: EN1默认参数值。
Oops. The error is in reference to the A::E::EN1 default parameter value.
哎呀。错误是参考A :: E :: EN1默认参数值。
Oops. The error is in reference to the A::E::EN1 default parameter value.
枚举器是枚举类型相同范围内的名称
被宣布。即要进入EN1,你说A :: EN1,而不是A :: E :: EN1。
Victor
Enumerators are names in the same scope where the enumeration type
is declared. I.e. to get to EN1, you say A::EN1, not A::E::EN1.
Victor
枚举器是枚举类型
Victor
Enumerators are names in the same scope where the enumeration type
is declared. I.e. to get to EN1, you say A::EN1, not A::E::EN1.
Victor
谢谢,Victor。感谢帮助。
Thanks, Victor. Appreciate the help.
这篇关于这合法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!