++: enum enumeration

#include<iostream>
using namespace std;

enum EColor:char
{
	Red,
	Blue,
	Yellow,
	White,
};
enum CColor :char
{
	Red,
	Blue,
	White,
};

int main()
{
	EColor TColor=EColor::Blue;
    return 0;
}

When using an enumeration enum, explicitly scope the enumeration name::Blue

Reduce encoding ambiguity

enum is filled in the order of 0, 1, 2, 3

enum EColor:char
{
	Red=10,
	Blue,
	Yellow,
	White,
};

Modify the value in the enumeration, but the value of the enumeration item is not allowed to be the same

Guess you like

Origin blog.csdn.net/Theolulu/article/details/129834886