C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
protected
                                             Up Contents Index Back
─────C/C++ Language─────────────────────────────────────────────────────────
 
  Keyword:   protected
 
  Syntax:    protected: [member-list]
             proctected base-class
 
  Summary:   When preceding a list of class members, specifies that
             those members are accessible only from member functions
             and friends of the class and its derived classes. Applies
             to all members declared up to the next access specifier or
             the end of the class.
 
             When preceding the name of a base class, specifies that
             the public and protected members of the base class are
             protected members of the derived class.
 
  See also:  public, private, friend
             Table of Access Privileges
 
     Default access of members in a class is private. Default access of
     members in a structure or union is public.
 
     Default access of a base class is private for classes and public
     for structures. Unions cannot have base classes.
 
     Example
 
         class BaseClass
         {
         protected:
             int protectFunc();
         };
 
         class DerivedClass : public BaseClass
         {
         public:
             int useProtect()
                 { protectFunc(); }    // protectFunc accessible
                                       //    from derived class
         };
 
         void main()
         {
             BaseClass aBase;
             DerivedClass aDerived;
 
             aBase.protectFunc();     // Error: protectFunc not
                                      //    accessible
             aDerived.protectFunc();  // Error: protectFunc not
                                      //    accessible in derived class
         }
                                    -♦-