answersLogoWhite

0


Best Answer

If this is a homework assignment, please consider trying to answer it yourself first, otherwise the value of the reinforcement of the lesson offered by the assignment will be lost on you.

To hide the data in a class in C++, simply declare the data private, and then manipulate the data using the public interface of the class.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How can you hide the data in a class in C plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

When class will be used and when structure will be used?

In class default members are private and in structure default members are public ,When ever you want to hide data from outside functions then you can use class.But in ANSI C we can hide data by using private access specifier.


How do you hide details of a class in C programming?

There are no classes in C and therefore no way to encapsulate information. Although it is possible to use structures containing both data and pointers to the functions that operate upon that data, and thus emulate object-oriented behaviour, all data is publicly accessible. To be hidden, data and implementation details need to be made private and there is no such mechanism in C.


What use of void data type in c plus plus?

doesn't return the value.


What are the objects used in dev c plus plus?

Objects in Dev C++ are the same as objects in generic C++, insofar as an object is an instance of a class.


Is there any possibility to hide a text file into an audio file using c plus plus?

i want full c language tutorial for our self study....with an easy mtho..and example also.....


What is disadvantage of structure over class in c plus plus programming?

Structures are public by default, while classes are private by default. As such, structures do no support data-hiding, which is a fundamental principal of object oriented programming. Although you can provide interfaces to the member variables of a structure, there is nothing to prevent a user from bypassing those interfaces and mutating the member variables directly, rightly or wrongly. Classes allow developers to hide data within the class itself, forcing users to make use of the provided interface to mutate the members in a carefully controlled manner, thus ensuring the members remain in a valid state at all times. By encapsulating all of the functionality within the class, users need not concern themselves with data validation; the class takes care of itself, only exposing what it needs to expose and nothing more.


What is c plus c plus 2c plus c plus c equal?

c + c + 2c + c + c = 6c


Is there any way to apply class diagram with structured programming language like C?

No. Class diagrams only apply to object-oriented languages where one class can inherit or derive from another. There is no inheritance model in C, thus data structures cannot be derived.


What is the c plus plus command to read a line?

You can use cin which located in iostream.h You have to use certain data type to read string, for instance, array of char


How do you hide the drive c?

DRIVE C IS KNOEN AS WINDOW DRIVE,SO ITS DIFFICULT TO HIDE DRIVE C.... but if you wnt to do so ,then install your window inanother drive......


Can you rewrite a cuda file in c c plus plus language?

Yes, you can rewrite a cuda program originally written in c in c plus plus.


How the turbo c plus plus use in the computer?

How the turbo c plus plus use what in the computer.