#include <iostream>
using namespace std;
enum Size {small, medium, large};
class Thing
{
public:
enum Color {red, white, blue}; // Color type belongs to the Thing class
enum {FALSE, TRUE
};
// anonymous enum
void setBigness(Size=small);
void setHue(Color=red);
Size getBigness() const;
Color getHue() const;
int amIBlue()
const
// implicit inline function
{ if (hue == blue) return TRUE; else return FALSE; }
private:
Size bigness;
Color hue;
};
void Thing::setBigness(Size s)
{
bigness = s;
}
void Thing::setHue(Color c)
{
hue = c;
}
Size Thing::getBigness() const
{
return bigness;
}
Thing::Color Thing::getHue() const // Why is Color qualified here?
{
return hue;
}
Thing::Color nonMember(const Thing&); // function prototype
int main()
{
Size S = large;
Thing::Color C = Thing::white;
Thing bigRedThing;
bigRedThing.setBigness(S);
bigRedThing.setBigness(medium);
bigRedThing.setHue();
cout << "I am"
<< (bigRedThing.amIBlue() ? " " : " not ")
<< "blue\n";
Thing littleBlueThing;
littleBlueThing.setBigness();
// littleBlueThing.setHue(blue);
littleBlueThing.setHue(Thing::blue);
cout << "I am"
<< (littleBlueThing.amIBlue() ? " " : " not ")
<< "blue\n";
littleBlueThing.setHue(C);
cout << "I am"
<< (littleBlueThing.amIBlue() ? " " : " not ")
<< "blue\n";
nonMember(bigRedThing);
}
Thing::Color nonMember(const Thing& T)
{
return T.getHue();
}