// Class members (data & methods) can be public/private/protected. // The default is private. // // public: anyone can access them // private: nobody except other methods of this class can access them // protected: can be accessed by this class, and by immediately derived class class Foo { // A class, with a variable of each type public: int pub; // I’m public! private: int priv; // I’m private! protected: int prot; // I’m a little teapot, short & stout. }; int main() { Foo f; f.pub = 1; // great // f.priv = 2; // nope // f.prot = 2; // nope return f.pub; }