C++ examples for Class:Class Creation
Using enum type within a Class
#include <iostream> using namespace std; class Cheesecake { public:/*from w w w . ja va2s. c o m*/ enum Flavor { A, B, C, D, E, F }; Flavor SelectedFlavor; int AmountLeft; void Eat() { AmountLeft = 0; } }; int main() { Cheesecake yum; yum.SelectedFlavor = Cheesecake::B; yum.AmountLeft = 100; yum.Eat(); cout << yum.AmountLeft << endl; return 0; }