C++ examples for Data Type:enum
Demonstrate enum types with day of week
#include <iostream> using namespace std; //specify enum type enum days_of_week { Sun, Mon, Tue, Wed, Thu, Fri, Sat }; int main()//from w ww . j a va2 s. c o m { days_of_week day1, day2; //define variables of type days_of_week day1 = Mon; day2 = Thu; int diff = day2 - day1; cout << "Days between = " << diff << endl; if(day1 < day2) cout << "day1 comes before day2\n"; return 0; }