这合法吗? [英] Is this legal?

查看:74
本文介绍了这合法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



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?

推荐答案

red floyd写道:
red floyd wrote:

A类{
public:
enum E {EN1,EN2,EN3};
};

B班{
公开:
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.


red floyd写道:
red floyd wrote:
red floyd写道:
red floyd wrote:

A类{
公开:
枚举E {EN1,EN2,EN3};
};

B级{
公开:
void f(const char * s,A :: E en = A :: E :: EN1);
};

`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.




枚举器是枚举类型相同范围内的名称

被宣布。即要进入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 Bazarov写道:
Victor Bazarov wrote:
red floyd写道:
red floyd wrote:
[枚举范围问题编辑]
[enumeration scope question redacted]


枚举器是枚举类型
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.


这篇关于这合法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆