
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
What are enumerated data types in C++?
An enumerated type declares an optional type name and a set of zero or more identifiers that can be used as values of the type. Each enumerator is a constant whose type is the enumeration. For example, if you are creating an application that has a fixed number of types for some variable. For example, let's say gender, it can be of three types male, female and others. You can define and use an enum like −
#include<iostream> using namespace std; enum Gender {MALE, FEMALE, OTHERS}; int main() { Gender gen = Gender.FEMALE; return 0; }
By default, the value of the first name is 0, the second name has the value 1, and the third has the value 2, and so on. But these values don't matter because enums are basically used to have a symbolic meaning. Whenever you compare an enum in your program, you'd be just using its symbolic meaning and not its actual value.
- Related Articles
- Explain Enumerated Types in JavaScript.
- Enumerated Types or Enums in C++
- What is enumerated data type in C language?
- What are Enumerated Constants in C++?
- What are primitive data types in Java?
- What are reference data types in Java?
- What are primitive data types in JavaScript?
- What are Complex Data types in JavaScript?
- What are pointer data types in C#?
- What are nullable data types in C#?
- What are dynamic data types in C#?
- What are object data types in C#?
- What are reference data types in C#?
- What are the data types, value types and reference types in C#?
- What are JavaScript data types and data structures?

Advertisements