Difference between revisions of "CPP/Enum"
From ProgrammingExamples
< CPP
Daviddoria (Talk | contribs) (Created page with '==Enum.cpp== <source lang="cpp"> #include <iostream> enum PointType { GOOD, BAD, UNINFORMATIVE }; int main(int argc, char *argv[]) { PointType A = GOOD; if(A == GOOD) …') |
Daviddoria (Talk | contribs) |
||
(One intermediate revision by one other user not shown) | |||
Line 4: | Line 4: | ||
enum PointType { GOOD, BAD, UNINFORMATIVE }; | 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[]) | int main(int argc, char *argv[]) | ||
Line 29: | Line 34: | ||
return 0; | return 0; | ||
} | } | ||
+ | </source> | ||
+ | |||
+ | ==CMakeLists.txt== | ||
+ | <source lang="cmake"> | ||
+ | cmake_minimum_required(VERSION 2.6) | ||
+ | |||
+ | PROJECT(Enum) | ||
+ | |||
+ | ADD_EXECUTABLE(Enum Enum.cpp ) | ||
+ | |||
</source> | </source> |
Latest revision as of 16:18, 17 April 2011
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; }
CMakeLists.txt
cmake_minimum_required(VERSION 2.6) PROJECT(Enum) ADD_EXECUTABLE(Enum Enum.cpp )