Example & Tutorial understanding programming in easy ways.

What is enum in C++?

What is Enum in C++ ?
Enum in C++ is a data type that contains fixed set of constants.
The C++ enum constants are static and final implicitly.

Example-
It can be used for days of the week:
-Monday
-Tuesday
-Wednesday
-Thursday
-Friday
-Saturday
-Sunday

Example of directions
(NORTH, SOUTH, EAST and WEST)

program:

#include < iostream>
using namespace std;
enum week { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday };
int main()
{
week day;
day = Tuesday;
cout << "Day: " << day+1<< endl;
return 0;
}


output-

Day: 2




Read More →
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!