Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ enum syntax

Tags:

c++

enums

After I declare

enum color {red, blue, green};

is there any difference between

color a=blue;

and

enum color a=blue;
like image 638
focusHard Avatar asked Dec 05 '22 10:12

focusHard


1 Answers

enum MyEnumType { ALPHA, BETA, GAMMA };

enum MyEnumType x;  /* legal in both C and C++ */
MyEnumType y;       // legal only in C++

enum { HOMER, MARGE, BART, LISA, MAGGIE };
like image 65
Ozan Deniz Avatar answered Dec 06 '22 23:12

Ozan Deniz