Q:

Enumerated data types and class APIs in C++

If you're supposed to encapsulate everything inside a class definition, how is it then possible to use enumerated data types with the class? For example I've just written the following code...
enum PizzaType {DEEP_DISH, HAND_TOSSED, PAN};
enum PizzaSize {SMALL, MEDIUM, LARGE};

class Pizza {
    public:
        Pizza();
        void setPizzaType(PizzaType type);
        PizzaType getPizzaType();
        void setPizzaSize(PizzaSize size);
        PizzaSize getPizzaSize();
        void setToppings(int toppings);
        int getToppings();
        void outputDescription();
        double computePrice();
    private:
        PizzaType pizzaType;
        PizzaSize pizzaSize;
        int totalToppings;
};

Is there any way of including the enumerated data types inside the class itself and yet still allow access to the mutator/accessor functions from outside?

A:

Yes, you can do it like this:
class Pizza {
    public:
        enum PizzaType {DEEP_DISH, HAND_TOSSED, PAN};
        enum PizzaSize {SMALL, MEDIUM, LARGE};

        Pizza();
        void setPizzaType(PizzaType type);
        PizzaType getPizzaType();
        void setPizzaSize(PizzaSize size);
        PizzaSize getPizzaSize();
        void setToppings(int toppings);
        int getToppings();
        void outputDescription();
        double computePrice();
    private:
        PizzaType pizzaType;
        PizzaSize pizzaSize;
        int totalToppings;
};

.. and then others have said, you just have to use the Pizza "namespace" in order to get to the enum types:
Pizza::PizzaType tmp = pPizza->getPizzaType();

etc, etc.
(As a note of style, when you put the enums inside of the class like this, I would personally remove the Pizza in front of it so that you have Pizza::Type and Pizza::Size.)

A:

class Pizza {
    public:
        enum PizzaType {DEEP_DISH, HAND_TOSSED, PAN};
        void setPizzaType(PizzaType type);
        PizzaType getPizzaType();
};
...
Pizza p;
p.setPizzaType( Pizza::DEEP_DISH );
Pizza::PizzaType pt = p.getPizzaType();

A:

The preferred method of using enums in C++ is to define them inside a class:
class Foo {
public:
     enum Bar {
         ENUM_VALUE1,
         ENUM_VALUE2
     };
};

Then, you can reference them using:
Foo::Bar var;
var = Foo::ENUM_VALUE1;

Inside the class, you can drop the Foo:: prefix.
As you have probably noticed, while the type of the enum is Foo::Bar, the values are not referenced through Foo::Bar::ENUM_VALUE1, but rather appear in the Foo's namespace. This may be problematic if different enums share the same value names. To avoid that, you can do the following trick:
class Foo {
public:
      struct Bar {
             enum ENUM {
                  ENUM_VALUE1,
                  ENUM_VALUE2
             };
      struct Baz {
             enum ENUM {
                  ENUM_VALUE1,
                  ENUM_VALUE2
             };
      };
};
Foo::Bar::ENUM e = Foo::Bar::ENUM_VALUE1;
Foo::Baz::ENUM e2 = Foo::Baz::ENUM_VALUE1;

