demonstrates enum types : enum « Data Type « C++






demonstrates enum types

   
#include <iostream>   
  using namespace std;   

  enum days_of_week { Sun, Mon, Tue, Wed, Thu, Fri, Sat };   
    
  int main() {   
     days_of_week day1, day2;  
                               
     day1 = Mon;               
     day2 = Thu;               
    
     int diff = day2 - day1;   
     cout << "Days between = " << diff << endl;   
    
     if(day1 < day2)           
        cout << "day1 comes before day2\n";   
     return 0;   
  }
  
    
    
  








Related examples in the same category

1.Using consts and enums in Arrays
2.Using bit fields.
3.demonstrates enums, counts words in phrase
4.demonstrates enumerations