answersLogoWhite

0


Best Answer

Inheritance is used to define a subclass of a common ancestor. In other words, if you have a class that performs a set of functions, then a class that uses inheritance would have all the functions of the parent class plus additional or modified functions unique to that specific subclass. This allows developers to group common functionality into one class, then provide overrides and additional functionality to child classes. This facilitates code reuse, reduction of code duplication, and polymorphic functions that can operate on several different types of objects using the same base code.

User Avatar

Wiki User

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

Wiki User

12y ago

Fortunately,C++ strongly support the concept of re-usability .the C++classes can be reused in several ways.Once a class has been written and tested ,it can be adapted by other programmers to suit their requirements.This is basically done by creating new classes, reusing the properties of the existing ones.This mechanism of deriving new class form an old one is called inheritance.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

There are 5 types of inheritance in C++. Using classes named A, B and C, we can describe all 5 as follows:

1. Single Inheritance: where A inherits from B.

2. Multilevel Inheritance: where A inherits from B and B inherits from C.

3. Hierarchical Inheritance: where A and B both inherit from C.

4. Multiple Inheritance: where A inherits from both B and C.

5. Hybrid Inheritance: Any combination of the above.

A typical example of hybrid inheritance is a combination of multiple inheritance and hierarchical inheritance, such that A inherits from both B and C (multiple inheritance), while B and C both inherit from D (hierarchical inheritance). In this situation, A inherits two indirect instances of D. That is, A::B::D and A::C::D. This creates ambiguity because you cannot implicitly refer to A::D. To remove the ambiguity, we can specify D as being a virtual base class of both B and C. When we do this, the most-derived class, A, invokes the D constructor, while B and C both share this one instance of D, virtually.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Inheritance simply means to derive a new class of object from an existing base class. The derived class inherits all the public and protected members of the base class, so the code in the base class can be re-used to suit a specific purpose, without having to rewrite all the code in the base class.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Hierarchical inheritance is simply a way of describing how derived classes relate to their base class or classes, similar to a family tree.

At the top of the tree is the base class. Below it are all the classes that derive from that base class. And below each of those are all the classes that derive from them. And so on.

Multiple inheritance, where a class is derived from two or more classes, tends to mess up the analogy slightly, because two classes may inherit from the same base class. For instance, suppose class A is the base class that forms the root, and class B and C both derive from A. If class D is derived from both B and C, then class D inherits two separate instances of class A -- one from B, the other from C. This introduces an ambiguity: when you call a method of A from within D, the compiler won't know which instance of A you are actually referring to unless you call the method explicitly via B or C. In other words, you must work up the hierarchical tree of inheritance via the correct branch to ensure the correct method is called.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

It is the inheritance which is a combination of two or more inheritance of the following : single, multiple,multilevel and hierarchal

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is hierarchical inheritence in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Can you declare a method within a method in c or c plus plus?

C: there are no methods in C. C++: no.


What is the different of c and c plus plus?

c is procedure oriented and c++ is object oriented & much newer.


How A plus B plus C plus D plus 80 plus 90 equal to 100 what is the value of A B C and D?

If a + b + c + d + 80 + 90 = 100, then a + b + c + d = -70.


In computer language C plus plus is related to?

C++ is related to C, the language from which it is derived.


What is meant by println in c plus plus?

println is not a C++ keyword.

Related questions

Does c plus plus supports hierarchical inheritance?

Yes.


What is multiple inheritence in c?

C is not object oriented and therefore has no concept of inheritance of any kind.


If your father-in-law leaves an inheritence to your husband are you intitled to some?

According to property laws, inheritence is considered separate property which is owned by the heir. A spouse is not entitled to inheritence.


What is b plus b plus b plus c plus c plus c plus c?

b+b+b+c+c+c+c =3b+4c


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

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


B plus b plus b plus c plus c plus c plus c equals?

b + b + b + c + c + c + c = 3b + 4c


What do you mean by inheritence?

Inheritence is somethingt that you are given. Like a gift in a way. ( Read Genesis 26 and 27)


Symplify c plus c plus c plus c?

4c


What is Mendelian inheritence?

Linkage


What is c plus c plus c plus c plus c?

c + c + c + c + c = 5 * c.


Primary and secondary key in c and c plus plus?

There are no "primary and secondary keys" in c and c plus plus.


What is c plus C plus C answer in algebra?

3c