Hi everyone. Sorry for my english. I would know only one question. What is ENUM in c++? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 8

Hi everyone. Sorry for my english. I would know only one question. What is ENUM in c++?

question

16th May 2018, 8:39 AM
Hackerman
Hackerman - avatar
5 Respostas
+ 8
Thanks. I understood. Really helpful comments
16th May 2018, 11:39 AM
Hackerman
Hackerman - avatar
+ 5
#include <iostream> using namespace std; enum week { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }; int main() { week today; today = Wednesday; cout << "Day " << today+1; return 0; } OUTPUT: day 4 i think u can understand from this program. just google it or you can refere it in course if c++ in this app, about defenition and relate with this program.
16th May 2018, 9:04 AM
Vijay Kumar Kanchukommala
Vijay Kumar Kanchukommala - avatar
+ 4
enumeration is a user defined data type that consists of integer constants. you can read more here gives some more info https://en.wikipedia.org/wiki/Enumerated_type
16th May 2018, 9:01 AM
Ben
Ben - avatar
+ 3
one more thing, "enum" ( unscoped ) causes lots of bugs because of the main cause that variables that you declare are global while scoped enum the variables are local. you should be using "enum class" ( scoped ) in C++. ex . enum Unit { Alpha, Beta, Gamma }; Unit u; u = Alpha; // Alpha is global int Alpha = 63; // Compiler generates errors enum class Unit { Alpha, Beta, Gamma }; Unit u; u = Unit::Alpha; // Alpha is local int Alpha = 63; // Compiles fine. I would recommend to read "Effective Modern C++" for more information about it.
16th May 2018, 11:32 AM
Cain Eviatar
Cain Eviatar - avatar
+ 1
An enumeration is a user-defined data type that consists of integral constants. To define an enumeration, keyword enum is used. enum season { spring, summer, autumn, winter };
16th May 2018, 9:54 AM
Rajeeb