Whats the difference between “public:”, “private:”, and “protected:”?
* A member (either data member or member function) declared in a private: section of a class can only be accessed by member functions and friends[14] of that class * A member (either data member or member function) declared in a protected: section of a class can only be accessed by member functions and friends[14] of that class, and by member functions and friends[14] of derived classes * A member (either data member or member function) declared in a public: section of a class can be accessed by anyone ================================================== ============================
• A member (either data member or member function) declared in a private section of a class can only be accessed by member functions and friends of that class • A member (either data member or member function) declared in a protected section of a class can only be accessed by member functions and friends of that class, and by member functions and friends of derived classes • A member (either data member or member function) declared in a public section of a class can be accessed by anyone [ Top | Bottom | Previous section | Next section | Search the FAQ ]