answersLogoWhite

0


Best Answer

One can always declare a datatype as static which will limit the scope to the file only. this way data hiding can be achived. For more clearance on the same please refer 'the C Programming language'.

Data hiding means only relevant data is visible to the user and all the background information is hidden from the user. In c++, the variables are named as data members and these can be hidden with the help of private access specifier.

In procedural languages, variables(global variables) are free to flow from functions to functions and hence they were not secured. But in C++, only the class in which the data members are being declared can access them by using private specifier. As, the data members and also member functions of a class cannot be accessed outside the class if they have private access so, they get hidden from the user and hence the data hiding is achieved.

Also in inheritance when we derive a class from the base class then the derived class cannot access the private members of the base class. In addition, if a class is derived from another class privately i.e. for example syntax : class B : private A , is used then all the public and protected members (not private) becomes private to class B and cannot be accessed outside the class B, even by using the object of class B.

Hence, data hiding is achieved in C++ through private access specifier.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: In ANSI C you can hide data by using private access specifier Justify?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is meant by private access in c plus plus?

It isn't. Private is the default access for class members. For struct members, the default access is public. Aside from default access, a class and a struct serve the same purpose; to define a class. As such, the following class definitions are equivalent: class X { int a; }; struct Y { private: int b; }; Typically, we use a struct to define simple data types with trivial construction and use class for more complex data types, often to encapsulate an invariant or to acquire a resource, hiding the implementation details from consumers using private access.


Define access specifiers in object oriented programming?

One of the techniques in object-oriented programming is encapsulation. It concerns the hiding of data in a class and making them available only through its methods. In this way the chance of making accidental mistakes in changing values is minimized. Java allows you to control access to classes, methods, and fields via so-called access modifiers. The access to classes, constructors, methods and fields are regulated using access modifiers i.e. a class can control what information or data can be accessible by other classes. To take advantage of encapsulation, you should minimize access whenever possible.Java provides a number of access modifiers to help you set the level of access you want for classes as well as the fields, methods and constructors in your classes. A member has package or default accessibility when no accessibility modifier is specified.Access Modifiers1. Private2. Protected3. Default4. PublicPublic is the most liberal access modifier and Private is the most restrictive access modifier. NB there is no such thing as an 'access specifier' in Java, only access modifiers.


Discuss about the visibility control of java program?

Visibility is another term used for Acess Specifiers for java variables and objects.One of the techniques in object-oriented programming is encapsulation. It concerns the hiding of data in a class and making them available only through its methods. In this way the chance of making accidental mistakes in changing values is minimized. Java allows you to control access to classes, methods, and fields via so-called access specifiers. The access to classes, constructors, methods and fields are regulated using access modifiers i.e. a class can control what information or data can be accessible by other classes. To take advantage of encapsulation, you should minimize access whenever possible.Java provides a number of access modifiers to help you set the level of access you want for classes as well as the fields, methods and constructors in your classes. A member has package or default accessibility when no accessibility modifier is specified.Access Modifiers1. Private2. Protected3. Default4. PublicPublic is the most liberal access specifier and Private is the most restrictive access specifier.


What is the valid class declaration header for the derived class d with base classes b1 and b2 A class d public b1 public b2 B class d class b1 class b2 C class d public b1 b2 D class d b1 b2?

What is the valid class declaration header for the derived class d with base classes b1 and b2?A. class d : public b1, public b2 {/*...*/};B. class d : class b1, class b2 {/*...*/};C. class d : public b1, b2 {/*...*/};D. class d : b1, b2 {/*...*/};The answer is A, C and D.B is not valid because "class" is not a valid access specifier.All the others are valid because private access is the default when the access specifier is omitted. Note that if class D were declared using the struct prefix, inheritance would default to public access rather than private.


What is access modifier?

An Access Modifier is a key word in java that determines what level of access or visibility a particular java variable/method or class has. There are 4 basic access modifiers in java. They are: 1. Public 2. Protected 3. Default and 4. Private Private is the most restrictive access modifier whereas public is the least restrictive. Default is the access protection you get when you do not specifically mention an access modifier to be used for a java object.

Related questions

What is the use of public access specifier?

use of public access specifier iswe can access the class members(methods,variables) out side the class using class reference


What is meant by private access in c plus plus?

It isn't. Private is the default access for class members. For struct members, the default access is public. Aside from default access, a class and a struct serve the same purpose; to define a class. As such, the following class definitions are equivalent: class X { int a; }; struct Y { private: int b; }; Typically, we use a struct to define simple data types with trivial construction and use class for more complex data types, often to encapsulate an invariant or to acquire a resource, hiding the implementation details from consumers using private access.


How the jvm is able to access your class even you declare it using default access specifier but the same class is not accessed from other class which is declared in another package?

The JVM knows about all of your classes, no matter what package they are in or what access specifier you declared them with. The access specifier is only used to limit access from other classes.


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.


Define access specifiers in object oriented programming?

One of the techniques in object-oriented programming is encapsulation. It concerns the hiding of data in a class and making them available only through its methods. In this way the chance of making accidental mistakes in changing values is minimized. Java allows you to control access to classes, methods, and fields via so-called access modifiers. The access to classes, constructors, methods and fields are regulated using access modifiers i.e. a class can control what information or data can be accessible by other classes. To take advantage of encapsulation, you should minimize access whenever possible.Java provides a number of access modifiers to help you set the level of access you want for classes as well as the fields, methods and constructors in your classes. A member has package or default accessibility when no accessibility modifier is specified.Access Modifiers1. Private2. Protected3. Default4. PublicPublic is the most liberal access modifier and Private is the most restrictive access modifier. NB there is no such thing as an 'access specifier' in Java, only access modifiers.


Discuss about the visibility control of java program?

Visibility is another term used for Acess Specifiers for java variables and objects.One of the techniques in object-oriented programming is encapsulation. It concerns the hiding of data in a class and making them available only through its methods. In this way the chance of making accidental mistakes in changing values is minimized. Java allows you to control access to classes, methods, and fields via so-called access specifiers. The access to classes, constructors, methods and fields are regulated using access modifiers i.e. a class can control what information or data can be accessible by other classes. To take advantage of encapsulation, you should minimize access whenever possible.Java provides a number of access modifiers to help you set the level of access you want for classes as well as the fields, methods and constructors in your classes. A member has package or default accessibility when no accessibility modifier is specified.Access Modifiers1. Private2. Protected3. Default4. PublicPublic is the most liberal access specifier and Private is the most restrictive access specifier.


How do you stop your neighbor from using your internet?

make it a private wireless internet by make it to where you have to put a password in to access it


Is it possible to access the private variable in CPP from outside the class?

Private variables can only be accessed from outside of a class by using any public function of that same class. Or this can be accomplished by using Friend functions.


On a runescape private server how do you make infinite hitpoints into an item?

Well, that is totally dependent on what private server you are using. But in most, you simply edit the "health" code/access # for that item.


How do you find flight details boarding from India to us using passenger name?

You - as a 'private citizen' have no right to access that information.


What is a sentence using the word justify?

Employees must justify any expenses of company funds. The standard of Western typing is to justify text to the left margin.


If you can Justify the choice of using the horizontal milling machine instead vertical milling machinefor making the baseplate?

Justify the using of the horizontal milling machine for making the baseplate