Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - The input method of enumeration type in c++ is
The input method of enumeration type in c++ is
You can directly use CIN>;; & gt input by enumerating variables.

Enumeration types, in C++, are essentially integer values, that is, int types.

Enumeration names are only for programmers and maintainers to read.

Such as enumeration

enum? test

{

Test 0,

TEST 1,

Test 2

}; In, the values of TEST0, TEST 1 and TEST2 are 0, 1, 2.

Therefore, for enumerated variables, their input and output can also be input and output according to int type.

such as

Enumeration test t;

CIN & gt; & gtt; //input

Cout & lt& lt "gets an enumeration t with the value"<& ltt<& ltendl///output.