What's the difference between a static data member and a regular data member?

What Is the Difference Between Private & Public Member Data?

  • Answer:

    The programming language C++ allows programmers to present data in certain ways. When a program is made up of many parts, there has to be a structure to implement the data. Just as a library arranges books in different fields, based on the system it uses, the program arranges its data in a certain way. Private Member Data C++ programming uses a category called private member data to restrict access to some information. Programmers classify data into various classes. If they specify that the data in a class is private, this means that only those who can access that class can access the data. Only those with such access can modify the data in the class. The program considers data in a class to be private, and this is the default setting, unless the programmer specifies otherwise. Public Member Data Another way of providing access to data in the C++ programming language is to specify that classes are public. This means that users who can access the code can access the input in a class. This is a less restrictive way of providing data access. In a passive data structure format, the data in a class is public by default. In a class format, which is an active data structure format, the data is private by default unless the programmer makes it public. Protected Access There is also another way of providing access in the C++ programming language. Protected access provides a form of user access that is not as restricted as private access, but makes for more restrictions than public access that is open to anyone. This sort of access provides access to certain data only from within a class or subclass. If programmers want to make some aspects of data public while restricting access to some subclasses of data, using protected access serves this purpose. Significance C++ programming makes use of specifiers that can be complex. Making use of the public access function gives users access to only certain information that they need to know, without having to go through the more complex specifiers. For instance, in case a class has three hundred data members and a hundred member functions, making all this input public makes for complexity. Instead, if the program is set up to restrict public access to only a few of the functions, it can simplify the program for users.

Corr S. Pondent at eHow old Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.