English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

How to return an array in the function of C++ ++ChainMap in Python

Enumeration is C / How to calculate the execution time of a code segment in C++ ++User-defined data type in the language. It is used to assign names to integer constants, making the program easier to read and maintain. The keyword 'enum' is used to declare enumeration.

The following is the syntax of enumeration.

enum enum_name{const1, const2, ……};

Here,

enum_name-Any name provided by the user.

const1, const2-These are the values of type flags.

The enum keyword is also used to define enum type variables. There are two ways to define enum type variables, as shown below:

enum colors{red, black};
enum suit{heart, diamond=8, spade=3, club};

The following is an example of enumeration.

Example

#include <iostream>
using namespace std;
enum colors{red=5, black};
enum suit{heart, diamond=8, spade=3, club};
int main() {
   cout << "The value of enum color : " << red << "," << black;
   cout << "\nthe default value of enum suit : " << heart << "," << diamond << "," << spade << "," << club;
   return 0;
}

Output result

The value of enum color : 5,6
The default value of enum suit : 0,8,3,4

In the above program, two enums are declared as color andmain()Function outside suitable.

enum colors{red=5, black};
enum suit{heart, diamond=8, spade=3, club};

In thismain()In the function, the value of the enum element is set.

cout << "The value of enum color : " << red << "," << black;
cout << "\nthe default value of enum suit : " << heart << "," << diamond << "," << spade << "," << club;
Kotlin Tutorial