answersLogoWhite
Software and Applications (non-game)
Computer Programming
Java Programming
C++ Programming

When to use multiple and multilevel inheritance?

222324

Top Answer
User Avatar
Wiki User
Answered 2006-09-04 07:51:02

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

001
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
๐Ÿ˜‚
0

Related Questions


Single Inheritance Multiple Inheritance Multilevel Inheritance


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


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,


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


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


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.


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


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.


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


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


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


In multilevel threading it has multiple kernals and multiple users.


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)


Desoola Anil Kumar, Java Faculty: There are 5 types of Inheritance. 1.Single inheritance, 2.Multiple inheritance, 3.Multilevel Inheritance, 4. Hirarichal inheritance and 5. Hybrid inheritance. Java supports multi level inheritance and hirarichal inheritance.


Multilevel InheritanceA Scenario where one class is inheriting/extending the bahavior of another class which in turn is inheriting behavior from yet another class.Ex: public class Automobile {&Atilde;&cent;&acirc;&sbquo;&not;&Acirc;&brvbar;}Public class Car extends Automobile {&Atilde;&cent;&acirc;&sbquo;&not;&Acirc;&brvbar;}Public class Ferrari extends Car {&Atilde;&cent;&acirc;&sbquo;&not;&Acirc;&brvbar;}This multilevel inheritance actually has no limitations on the number of levels it can go. So as far as java goes, it is limitless. But for maintenance and ease of use sakes it is better to keep the inheritance levels to a single digit number.Multiple InheritanceActually, java does not support multiple inheritance. You can achieve partial multiple inheritance using interfaces but java is not like C or C++ where you can do direct multiple inheritance. However, you can achieve partial multiple inheritance with the help of interfaces.Ex: public class FerrariF12011 extends Ferrari implements Car, Automobile {&Atilde;&cent;&acirc;&sbquo;&not;&Acirc;&brvbar;}And this is under the assumption that Car and Automobile are interfaces.Here if you see, though you don't inherit concrete code from the Car or the Automobile interface, you do inherit skeleton methods that determine the way your class eventually behaves and hence this can be considered partial Multiple Inheritance.


Multiple Inheritance : we can inherit more than one class in the same class. Multi-Level Inheritance: where one class can inherit only one base class and the derived class can become base class of some other class.


Multilevel inheritance is when there is a multiple father child hierarchy in your application. Ex: class A extends class B class B extends class C class C extends class D This means class A extends class D indirectly through classes B and C.


Grandfather-father-child relationship is an example for multi level inheritance..


Yes, you are right, you can use multiple inheritance in c plus plus and not in Java. What is the question?


in java inheritance does not support multiple inheritance therefore we use interface.where as in c plus plus supprot the multiple inheritance.


In java we can implement more than one interfaces for a single class but we can't extend a class to more than one super class so ,java indirectly supports multiple inheritance.


Multilevel InheritanceA Scenario where one class is inheriting/extending the bahavior of another class which in turn is inheriting behavior from yet another class.Ex: public class Automobile {&Atilde;&cent;&acirc;&sbquo;&not;&Acirc;&brvbar;}Public class Car extends Automobile {&Atilde;&cent;&acirc;&sbquo;&not;&Acirc;&brvbar;}Public class Ferrari extends Car {&Atilde;&cent;&acirc;&sbquo;&not;&Acirc;&brvbar;}This multilevel inheritance actually has no limitations on the number of levels it can go. So as far as java goes, it is limitless. But for maintenance and ease of use sakes it is better to keep the inheritance levels to a single digit number.


single level inheritance eg ( class B extends Class A) Multilevel inheritance eg( class C extends class B and class B extends class A) multiple inheritance Class C inherits Class A features as well as Class B featues.This type of inheritance is not allowed in JAVA.


C is not object-oriented -- you can't even use single inheritance let alone multiple inheritance.


Yes - If the variable is public or has a public getter method No - If it is private



Copyright ยฉ 2020 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.