Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "enum class" mean in Visual C++ 2012?

There are two conflicting definitions of enum class in Visual C++ 2012:

  • The C++11, type-safe version of enum
  • The C++/CLI, System::Enum derived type, equivalent to a ref class with static const integral members.

Does the meaning of enum class change when you enable or disable the /clr switch?

like image 210
Asik Avatar asked Mar 15 '26 00:03

Asik


1 Answers

A managed enumeration must have an access specifier (either public or private). A C++11 scoped enumeration must not have an access specifier. For example,

enum class E { e0 };

public enum class F { f0 };
private enum class G { g0 };

E is valid in C++, C++/CLI, and C++/CX, and it is an ordinary C++ scoped enumeration.

F and G are valid only in C++/CLI and C++/CX, and they name a managed enumeration (in C++/CLI) or a Windows Runtime enumeration (in C++/CX).

like image 175
James McNellis Avatar answered Mar 17 '26 12:03

James McNellis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!