The private access specifier declares private members of a class. It is also used to inherit a base class privately. When used to declare private members, it has this general form:

 class class-name {      // ... private:      // private members };

Since members of a class are private by default, the access specifier private will only be used in a class declaration to begin another block of private declarations. For example, this is a valid class declaration:

class myclass {   int a, b; // private by default public: // begin public declarations   int x, y; // these are public private: // return to private declarations   int c, d; // these are private };

When used as an inheritance specifier, private has this general form:

class class-name : private base-class { // ...

By specifying a base class as private, all public and protected members of the base class become private members of the derived class. All private members of the base class remain private to it.

C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539 © 2008-2017.
If you may any questions please contact us: