CPP/Enum

From ProgrammingExamples
< CPP
Revision as of 10:00, 23 June 2010 by Nbaztec (Talk | contribs)

Jump to: navigation, search

Enum.cpp

#include <iostream>
 
enum PointType { GOOD, BAD, UNINFORMATIVE };
/*
 * Other Ways:
 * enum PointType { GOOD = 3, BAD = 6, UNINFORMATIVE = 9};
 * enum PointType { GOOD = 2, BAD, UNINFORMATIVE }; GOOD =2,BAD =3,so on...
 */
 
int main(int argc, char *argv[])
{
  PointType A = GOOD;
 
  if(A == GOOD)
  {
    std::cout << "good" << std::endl;
  }
  else
  {
    std::cout << "not good" << std::endl;
  }
 
  if(A == BAD)
  {
    std::cout << "not working" << std::endl;
  }
  else
  {
    std::cout << "working" << std::endl;
  }
 
  return 0;
}