public private and protected membersclass members


Public, Private and Protected members:

Class members can either be declared in public','protected' or in the 'private' sections of the class. But as one of the features of OOP is to stop data from unrestricted access, the data members of the class are normally declared in the private section. The member functions that form the interface among the object and the program are declared in public section (or else these functions can not be called from the program ). The member functions which may have been broken down further or those, which do not form a part of the interface, are declared in the private section of the class. By default all the members of the class are private.

The third access specifier 'protected' that is not used in the above example, pertains to the member functions of some new class that will be inherited from the base class. As far as non-member functions are concerned, private and protected are one  and the similar.

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: public private and protected membersclass members
Reference No:- TGS0309358

Expected delivery within 24 Hours