开发者

Why could an enum type be used without defined

开发者 https://www.devze.com 2023-01-20 08:45 出处:网络
I am using VC2008 as my complier, and it is surprised to me that an enum could be used without defined:

I am using VC2008 as my complier, and it is surprised to me that an enum could be used without defined:

void func(enum EnumType type)
{

}

Code above could be compiled and run without a problem, could anyone explain why it works?

Update: I could define an empty enum in C++, as follow:

enum EnumTy开发者_C百科pe {};


This is evidently a nonstandard Visual C++ language extension.

You cannot forward declare an enum in standard C++.

0

精彩评论

暂无评论...
验证码 换一张
取 消