Declaring members with access restrictions

The initial level of access to an attribute is set in the class declaration. The specifiers public, private and protected can be used to define sections of the declarations of a class with the corresponding protection.

class mylinkage {
private:
   mylinkage * prev;
   mylinkage * next;
protected:
   void set_prev(mylinkage* L);
   void set_next(mylinkage* L);
public:
   mylinkage * succ();
   mylinkage * pred();
   mylinkage();
};

If no access specifiers are given, an attribute is private by default. It is safer and clearer to always use the specifiers explicitly.

If the first access specifier is used after some declarations, these are assumed to be private.


Next note in series

Back to index