Class Access Modifiers
Data hiding is one of the important features of Object
Oriented Programming which allows preventing the functions
of a program to access directly the internal representation
of a class type. The access restriction to the class members
is specified by the labeled public, private, and protected
sections within the class body. The keywords public, private,
and protected are called access specifiers.
A class can have multiple public, protected, or private labeled
sections. Each section remains in effect until either another
section label or the closing right brace of the class body is seen.
The default access for members and classes is private.
class Base {
public:
// public members go here
protected:
// protected members go here
private:
// private members go here
};
No comments:
Post a Comment