C++ enum types with day of week

Description

C++ 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()// w  ww.ja v  a  2  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;
}



PreviousNext

Related