answersLogoWhite

0

Inheritance

Updated: 8/10/2023
User Avatar

Mr Answers

Lvl 11
2y ago

Best Answer

The process by which physical and biological characteristics are transmitted from the parent (or parents) to the offspring.

User Avatar

Mr Answers

Lvl 11
2y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

8y ago

In computer programming, inheritance describes the way in which a new class of object can be derived from one or more existing classes known as base classes. In this way it becomes possible to create new classes based upon existing classes which already provide the basic functionality required of the derived class without the need to write duplicate code to implement that functionality.

A base class is simply a class which has a virtual destructor or is itself derived from a base class but is not declared final. Classes without virtual destructors should not be used as base classes and final classes cannot be used as base classes. Derived classes inherit all the public and protected members of their base classes but none of the private members. Derived classes may override any virtual method of their base classes in order to provide a more specialised implementation of the virtual interface. Abstract base classes are a special type of base class which provide a virtual interface but need not provide a complete implementation for that interface; the derived class is expected to provide the complete implementation for that interface (if a derived class does not provide or inherit a complete interface, it too becomes an abstract base class).

There are two types of inheritance: single inheritance and multiple inheritance. With single inheritance, every class in the hierarchy derives directly from one base class such that no class appears more than once within the hierarchy. For instance, a square class may inherit directly from a rectangle class which may inherit directly from a shape class. As such we can say that a square is a type of rectangle which is a type of shape. We can therefore pass a square into any function that expects a shape or rectangle object because a square is covariant with both a rectangle and a shape. We can also say that a square is a specialisation of a rectangle, which is itself a specialisation of a shape.

With multiple inheritance, a class may inherit from two or more base classes and any base class may appear more than once in the hierarchy. For instance, boats and cars may derive from a common vehicle base class, but an amphibious vehicle is both a boat and a car and may therefore derive from the boat and car base classes. Since boats and cars both derive from the vehicle base class, this would then mean an amphibious vehicle has two vehicle base classes, one inherited from the boat class and one inherited from the car class. In many cases it would be undesirable to have two separate base classes of the same type, however through multiple inheritance we can combine these separate but common classes into a single virtual class. This is achieved by declaring the vehicle class as a virtual base of the boat and car classes. The most-derived class in the hierarchy then (indirectly) inherits just one instance of the virtual base and is then responsible for the construction of that base, rather than those classes which inherit directly from it.

Whenever we invoke a virtual method of a base class, we would rightly expect the most-derived override of that method to be invoked. This is achieved automatically through a virtual function table. While there is a runtime cost in calling virtual functions, the cost is minimal because there is no need to explicitly invoke the runtime type information on an object in order to determine which override to call. This is known as runtime polymorphism, however this only works when we refer to a base object by reference or by pointer. If we refer to a base object by value, we lose polymorphic behaviour because the object has been "sliced" to the extent that the most-derived class is now the base class itself. This behaviour is often undesirable, however modern object oriented languages, such as Java, prevent this by ensuring that all objects are passed by reference (only the reference is passed by value, not the object being referred to). In lower level languages such as C++, the programmer is entirely responsible for ensuring polymorphic objects are passed by reference rather than by value.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

Inheritance is a relationship between objects. An example could be banking.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Inheritance
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Does hybrid inheritance consist of ANY two types of inheritance?

There are only two types of inheritance to begin with: single inheritance and multiple inheritance. Since they are mutually exclusive there is no such thing as hybrid inheritance.


Is a cash inheritence community property?

No. An inheritance is separate property.No. An inheritance is separate property.No. An inheritance is separate property.No. An inheritance is separate property.


Different types of inheritances?

Single Inheritance Multiple Inheritance Multilevel Inheritance


Define of inheritance?

clearly define inheritance and the reason behind using inheritance


Specialization form of inheritance?

Inheritance refers to the concept by which the features from one class can be extended/made available in other classes. Java supports 3 forms of inheritance * Single Inheritance * Multiple Inheritance * Multilevel Inheritance (Can be implemented using interfaces)


What is the name of the last Inheritance book?

Inheritance


What is inheritance cash?

"Inheritance cash is just like any other inheritance, except it's money as opposed to land or a house or other assets." An inheritance is something that is left to you by a family member who has passed away. Inheritance cash is just the money form of an inheritance.


How can one get an inheritance advance?

If you are due an inheritance that is in probate, or will receive an inheritance that is in trust it might be possible for you to get an inheritance advance. There are numerous companies online that offer this service. Loans are usually to the value of 50-60% of your inheritance.


Does the inheritance of one trait effect the inheritance of another trait?

Inheritance all traits is independent, according to the Law of inheritance, unless there is linkage in the genes.


Who wrote the book Inheritance?

"Inheritance" was written by Christopher Paolini. It is the fourth book in the Inheritance Cycle series.


What type of inheritance is eye color?

polygenic inheritance


Does Minnesota have an inheritance tax?

No. Minnesota does not have an inheritance tax.