C++ examples for Data Type:enum
An enumerated data type is useful to keep track of features
enum ShapeType {/*from w w w . j a v a 2s . co m*/ circle, square, rectangle }; // Must end with a semicolon like a struct int main() { ShapeType shape = circle; // Activities here.... // Now do something based on what the shape is: switch(shape) { case circle: /* circle stuff */ break; case square: /* square stuff */ break; case rectangle: /* rectangle stuff */ break; } }
Add initialized value for enum value.
enum ShapeType {
circle = 10, square = 20, rectangle = 50
};
The compiler can and will use the next integral value if you miss it.
enum snap { crackle = 25, pop };