Best Answer

Multiple inheritance is likely to be most useful when you can separate the characteristics of objects into orthogonal sets, in which the characteristics of one set do not depend on the characteristics of other sets. If you can define a class to represent each set of characteristics, you can use multiple inheritance to build complex classes with different combinations of characteristics. We gave a glimpse of how to create such a design by starting to segregate characteristics of flying and ground vehicles, and then noting that certain vehicles, like such as aircraft, can combine both sets of characteristics. Another approach that can be useful for various applications is to create one or more base superclasses, which define common characteristics of subclasses, and a number of mix-in classes, each of which adds a set of orthogonal characteristics. A mix-in class is like an addition, such as Chocolate Chips or nuts, that might be mixed into an ice-cream base. Another way to think about this approach is to imagine the base class as a noun and the mix-in classes as adjectives that modify or specialize the noun. You can then construct concrete subclasses by using multiple inheritance. For each concrete subclass, one or more mix-in classes typically precede a single base class in the list of superclasses. EXAMPLE : define abstract class () slot identifier :: , required-init-keyword: id:; ... end class ; define abstract class () slot vehicle-id :: , required-init-keyword: id:; ... end class ; define class () slot name :: , init-keyword: name:; ... end class ; define class () slot name :: , required-init-keyword: name:; ... end class ; Multiple inheritance provides several advantages in solving the name problem: 1. We localize in a single class the characteristic of having a name. 2. Subclasses can still customize aspects of the name attribute, such as what that attribute's initial value is, and whether or not it is required. 3. We can give a subclass a name attribute without redefining any of its superclasses. 4. The only subclasses that have a name attribute are those for which that is appropriate. MULTI LEVEL INHERITANCE: I believe this i got this code from others it may helps u: just experiment on it: OK, here's the code n check it: 1195c1195 < IND(s); s // scoped name. Have to use the alias for the base class in the > // global scope to refer to the virtual member function instead. > if (strcmp(intf_name,intf->wrapproxy_uqname()) != 0) { > intf_name = new char[strlen(intf->_scopename())+ > strlen(intf->wrapproxy_uqname())+1]; > strcpy(intf_name,intf->_scopename()); > strcat(intf_name,intf->wrapproxy_uqname()); > } > } > s } > s IND(s); s INC_INDENT_LEVEL(); > IND(s); s

User Avatar

Wiki User

โˆ™ 2006-09-04 07:51:02
This answer is:
User Avatar
Study guides


See all cards
25 Reviews

Add your answer:

Earn +20 pts
Q: When to use multiple and multilevel inheritance?
Write your answer...
Still have questions?
magnify glass
Related questions

Different types of inheritances?

Single Inheritance Multiple Inheritance Multilevel Inheritance

What is Hybrid Inheritance in CPP?

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

What are the similarities of java and c plus plus?

Most of the c++ is same as Java. but the major difference is c++ supports multiple inheritance whereas java does not. java only supports single level inheritance and multilevel inheritance there is a lot of difference between multiple and multilevel inheritance

Inheritance not supported by java?

Java supports 2 types of inheritance directly: Single &amp; multilevel Java does not support multiple inheritance directly. We can implement multiple inheritance by using interfaces but direct multiple inheritance is not supported by Java

What are the different types of inheritance?

there are several type of inheritance are exist like 1. single inheritance 2. double inheritance 3. multiple 4. multilevel 5. heirarchical inheritance

What do you mean by multiple inheritance and multilevel inheritance?

is aterm that refers to a class that inherits functionality from more than one parent class.

Difference between multilevel inheritence and multiple inheritence?

Multiple Inheritance is when one class inherits the features of multiple classes simultaneously. Note: Java does not support direct multiple inheritance Multilevel Inheritance is when the properties of one class are extended by another class through some other class. Ex: public class A extends B { ... } public class B extends C { ... } public class C extends D { ... } Now Class A indirectly extends class D through B &amp; C This is multilevel inheritance Note: Java allows multilevel inheritance till any number of levels.

What is the Difference between multiple inheritance and multilevel inheritance in

Multiple inheritance, as the name 'multiple' suggests, is one where more than one(multiple) super class is inherited by one sub-class. It can be represented as:A B C\ | /DOn the other hand, in case of multilevel inheritance; the superclass is inherited by a sub-class which is in turn inherited by another class leading to the different level. It can be represented as:A|B|CHowever in asp, multiple inheritance is not supported.

When will you use multiple inheritance and when will you use multi level inheritance?

Multiple inheritance is used when a new class to be formed has to inherit characteristics from two or more classes. eg: class scientist class labourer | | | | V V -------------------------------- | class employee | -------------------------------- Multilevel inheritance is used if a derived class inherits characteristics from a base class which is a derived class (intermmediate base class). If the inheritance level is more than two then it is a multilevel inheritance. eg: class Grandfather | | V class Father | | V class son

Dicuss the different types of inheritance?

Types of InheritanceThere exists basically three types of inheritanceMultilevel inheritanceMultiple inheritanceHierarchical inheritanceIn single inheritance, one class extends one class only. In multilevel inheritance, the ladder of single inheritance increases. In multiple inheritance, one class directly extends more than one class and in hierarchical inheritance one class is extended by more than one class. Let us go in detail programmatically.1. Multilevel InheritanceIn multilevel, one-to-one ladder increases. Multiple classes are involved in inheritance, but one class extends only one. The lowermost subclass can make use of all its super classes' members. Multilevel inheritance is an indirect way of implementing multiple inheritance. Following program explains.2. Multiple InheritanceIn multiple inheritance, one class extends multiple classes. Java does not support multiple inheritance but C++ supports. The above program can be modified to illustrate multiple inheritance. The following program does not work.3. Hierarchical InheritanceIn hierarchical type of inheritance, one class is extended by many subclasses. It is one-to-many relationship. A realtime example is available at dynamic binding.Biswajit Das,

Difference between single inheritance and multiple inheritance?

single inheritance A class derived from only one base class multilevel inheritance A class derived from another derived class s.gunasekaran VSBEC

What is multilevel threading?

In multilevel threading it has multiple kernals and multiple users.

People also asked