Using Enum

	enum name {enumeration list} optional varaible(s);
Examples

	enum colour_type {red, green, blue} colour;	//The variable colour can only be assigned the
									values red, green or blue
	(red = 0, green = 1, blue = 2 will be done by the compiler - these are basically const values)


	enum colour_type {red, green = 9, blue} colour;		//red = 0, green = 9, blue = 10


	enum colour_type {red, green, blue};
	colour_type colour;
	colour = green;
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published.