Same Program Using Constant Integers : const « Language Basics « C++ Tutorial






#include <iostream>
int main()
{
   const int Sunday = 0;
   const int Monday = 1;
   const int Tuesday = 2;
   const int Wednesday = 3;
   const int Thursday = 4;
   const int Friday = 5;
   const int Saturday = 6;

   int today;
   today = Monday;

   if (today == Sunday || today == Saturday)
      std::cout << "\nGotta' love the weekends!\n";
   else
      std::cout << "\nBack to work.\n";

   return 0;
}








1.8.const
1.8.1.Define constant
1.8.2.Demonstrates constants
1.8.3.const double value
1.8.4.Using a properly initialized constant variable.
1.8.5.Same Program Using Constant Integers
1.8.6.Demonstrating the const type qualifier