answersLogoWhite

0


Best Answer

Yes. If the variables are public yes they can be inherited. If they are private then they cannot be inherited. But to access these private variables you can have accessor methods that are public and can be accessed everywhere.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Encapsulation data we can inherit out side the class?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How data secured from out side world in c plus plus?

In C++, data is not secured from the outside world it is merely protected from accidental mutation. A determined programmer can easily circumvent the encapsulation of an object. Consider the following: class X { int data; // private by default }; Here, the data member is declared private (the default access for a class), however the class definition exposes the implementation details making it possible to define the exact same class with public access under a different name: struct Y { int data; }; Given that X and Y both have the same memory layout, it is trivial to undermine the encapsulation of an X by casting to a Y: void f (X& x) { x.data = 42; // error: x.data is private Y& y {(Y&) x}; // refer to x as if it were really a Y with pubic access y.data = 42; // ok }


How class accomplish data hiding?

Data hiding is one of the important aspects of a class. Data hiding means to hide the members of the class and providing the access to only some of them. we can make the members of the class private or public. in private,the outside world cannot access those members which been made private.and rest we can make public.only the public members are accessed by the out side world and all the private members can be accessed using only the public members.in this way a class provides security to its data members.


What is class in oops concept?

Classes are the integral part of the all-important programming paradigm known as Object-Oriented Programming(OOP). In OOP, a programming problem is perceived as a problem in a real-life scenario, as an interaction between objects. The problem is tackled by having a system of interacting objects, that interact among themselves to solve the programming problem. Objects in OOP bear semblance to real-life objects. Classes serve as templates for the creation of objects of the same type. For instance, students may be thought to be objects of the human-being class, cars may be thought to be objects of the Automobile class. Classes are defined as collection of methods(functions) and data members(variables), additionally defined by scope rules. In addition, classes also achieve the OOP principles of encapsulation, abstraction, polymorphism and inheritance. Encapsulation refers to binding data and code together, with data controlling access to code. Abstraction refers to the hiding the implementation details of a class from outside functions and exposing only necessary details. Polymorphism refers to the scenario when a class can play more than one role. Inheritance is used when one or more classes must include properties of another set of classes, and also have properties of their own.


Is a wheelbarrow second class lever?

No. It's a second class lever. A 1st class one has the pivot in the centre.


What is the difference between modular programming and structured programming.?

Modular programming:It is the act of designing and writing programs as interactions among functions that each perform a single well defined function,& which have minimal side effect interaction between them.It is heavily procedural.The focus is entirely on writing code(functions). Data is passive.Any code may access the contents of any data structured passed to it. Object Oriented programming:it is a programming paradigm using "objects"-data structures consisting of data fields & methods together with their interactions-to design applications and computer programs.programming techniques may include features such as data abstraction,encapsulation,messaging,modularity,polymorphism and inheritance.

Related questions

How data secured from out side world in c plus plus?

In C++, data is not secured from the outside world it is merely protected from accidental mutation. A determined programmer can easily circumvent the encapsulation of an object. Consider the following: class X { int data; // private by default }; Here, the data member is declared private (the default access for a class), however the class definition exposes the implementation details making it possible to define the exact same class with public access under a different name: struct Y { int data; }; Given that X and Y both have the same memory layout, it is trivial to undermine the encapsulation of an X by casting to a Y: void f (X& x) { x.data = 42; // error: x.data is private Y& y {(Y&) x}; // refer to x as if it were really a Y with pubic access y.data = 42; // ok }


If you have a flat butt from your mother but on your father side your grandmother has a big butt will you inherit that big butt?

Genetics controls the answer, there is always a chance to inherit anything.


How class accomplish data hiding?

Data hiding is one of the important aspects of a class. Data hiding means to hide the members of the class and providing the access to only some of them. we can make the members of the class private or public. in private,the outside world cannot access those members which been made private.and rest we can make public.only the public members are accessed by the out side world and all the private members can be accessed using only the public members.in this way a class provides security to its data members.


What is scoped data?

Scoped data refers to data that is limited in its visibility or access within a specific scope, such as within a function, module, or class. This helps to organize and control the flow of data within a defined context, preventing unintended side effects or conflicts with other parts of the program. Scoped data is typically only accessible within the boundaries of its scope.


What is the high side and what is the low side?

The high side is the rich class of people with nice jobs. The low side were the poor and lower class jobs.


Which side of a CD contains the data?

the shiny side/smaller ring inside has the data coz u could put a cover on the other side


Does the printed side of a CD contain data?

No the side with the data is the non printed side simply because there is less for the read/write head of the drive to see through when moving data onto or off the disk


Who represents the prosecution in the play Inherit the Wind?

Matthew Harrison Brady is the prosecuting attorney in the play, Inherit the Wind. Tom Davenport is M.H. Brady's assistant. In the play, these two help defend the prosecuting side of the case.


What is class in oops concept?

Classes are the integral part of the all-important programming paradigm known as Object-Oriented Programming(OOP). In OOP, a programming problem is perceived as a problem in a real-life scenario, as an interaction between objects. The problem is tackled by having a system of interacting objects, that interact among themselves to solve the programming problem. Objects in OOP bear semblance to real-life objects. Classes serve as templates for the creation of objects of the same type. For instance, students may be thought to be objects of the human-being class, cars may be thought to be objects of the Automobile class. Classes are defined as collection of methods(functions) and data members(variables), additionally defined by scope rules. In addition, classes also achieve the OOP principles of encapsulation, abstraction, polymorphism and inheritance. Encapsulation refers to binding data and code together, with data controlling access to code. Abstraction refers to the hiding the implementation details of a class from outside functions and exposing only necessary details. Polymorphism refers to the scenario when a class can play more than one role. Inheritance is used when one or more classes must include properties of another set of classes, and also have properties of their own.


Where is the data port on a 1997 Dodge Intrepid?

The data link connector is under the dash on the driver side.The data link connector is under the dash on the driver side.


In a Pentium the front side data bus is how many bits wide?

For the Pentium the front side data bus is 64 bits wide. The back side is 32 bits wide.


Can you inherit fraternal twins on your dad side?

twins skip a generation, but according to statistics, either female or male may produce them