Explain public and private members, C/C++ Programming

Assignment Help:

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.

 


Related Discussions:- Explain public and private members

MINIMUM SHELVES, Write a program to find minimum number of shelves

Write a program to find minimum number of shelves

Arrys, Write a program that allows user to enter number of elements in an a...

Write a program that allows user to enter number of elements in an array. The program then allows user to enter the elements. Write a function called max that returns the position

Volume, how to find the volume of cone , cylinder and sphere ?

how to find the volume of cone , cylinder and sphere ?

Operator overloading - c++ program, Operator overloading - c++ program: ...

Operator overloading - c++ program: Write a program in c to define operator overloading. class matrix{                   private :                 int x[2][2];

Functions, what is the difference between call by reference and call by poi...

what is the difference between call by reference and call by pointer method?

Change to palindrome, A palindrome is a string that reads the same from bot...

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

Train Station Schedule, Train Station C++ Program A C++ program that provi...

Train Station C++ Program A C++ program that provides a simple text based interface that will allow a user to create, edit, search, or delete a train schedule. The program will m

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd