answersLogoWhite

Top Answer
User Avatar
Wiki User
Answered 2011-01-11 13:14:39

Yes an abstract class can inherit from another abstract class but all the methods of the base abstract class must be abstract.

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

Your Answer

Related Questions


In C++, an abstract data type is a class that must be derived into a child class. It is not possible to instantiate an abstract class. Another way to define this is to say that an abstract class contains pure virtual functions or that it inherits from a class with pure virtual functions but does not provide an implementation for them.


Any class that has one or more pure-virtual functions is an abstract class.


abstract class no defination used by derieved class where virtual base class is defination that can be overriden later on


An abstract class is an abstract data type (ADT). They are used to describe a common interface to the objects that derive from them. You cannot instantiate objects from abstract classes, they must be derived from. Only derivatives that fully implement all the virtual methods they inherit from their ADTs can actually be instantiatedA virtual class is used in multiple inheritance cases where a derived class inherits from two or more base classes that each inherit from a common base class. The common base class must be declared virtual in all its derivatives to ensure only one instance of the common base class is present in any classes that inherit from two or more of the derived classes. Without virtual inheritance, the most-derived class would have multiple instances of the common base class, which introduces an undesirable ambiguity to the class.For instance, if you declare an animal ADT from which winged_animal and mammal are both derived, a bat class would inherit two animal ADTs as it is both a mammal and a winged_animal. To avoid this, animal needs to be declared a virtual inherited class in both mammal and winged_animal. Now bat will inherit only one animal ADT and the ambiguity is completely removed.



An abstract class is any class definition that contains at least one pure-virtual function. class AbstractClass { public: virtual void DoSomething()=0; // Pure-virtual. };


An abstract data type is any class or struct that contains at least one pure virtual function.


An abstract class is a class which has atleast one pure virtual function.An abstract class does not have any objects.It is used just for sharing it's members to some other classes.the class that shares the members of base class should define the pure virtual function if not object is not been created for example: class classname { protected: virtual datatype fname(parameters)=0; };


An abstract class is a class that contains at least one pure virtual function. A definition is not needed for pure virtual functions, as derived classes must override them. virtual void foo() = 0; Abstract classes cannot be instantiated. They provide a template for derived classes, and you can also point to them with pointers to utilize polymorphism. Additionally, a class derived from an abstract class must override ALL of the pure virtual functions, in order to make the class concrete. Implementing fewer than all of them will automatically make the derived class abstract, and instantiation of the derived class will not be possible.


A derived class is any class that inherits from another class (known as a base class). Derived classes can inherit from several base classes (multiple inheritance). Base classes may themselves be derived from other classes. Each derivative expands upon the functionality of its base class, making it more specialised. Derived classes inherit all the public and protected members of their base classes, except the constructors. Friends of base classes are not inherited either. An example of class inheritance declaration: class myDerivedClass : public myBaseClass { public: myDerivedClass(); };


To provide a generic interface for two or more concrete classes.


A generic class is a class that contains one or more virtual methods and is intended to act as a base class for more specific, specialised classes, known as derivatives or derived classes. A generic class that has one or more pure virtual methods is also known as an abstract base class or abstract data type.


An abstract base class may have member variables. Whether or not it actually needs member variables depends on the nature of the base class itself. If the variable is common to all derived classes, then it makes sense to place the variable in the base class. If some derived classes have no need of the variable, then it is better to derive an intermediate class with the variable, and to derive those classes that require that variable from the intermediate class, rather than directly from the abstract class.


The interface of a C++ class is the public methods and attributes that are exposed by the class. In a pure abstract base class, the interface is enforced by the compiler in each of the derived child classes.


An abstract class is a class that has a pure virtual function. A pure virtual function can be used in a base class if the function that is virtualised contains parameters that can and should be interchangeable, but the function should remain intact. For example, there is a base class Object in a game that will contain movement for simple objects, but the movement function may need to use different parameters per object.


Yes, you can declare a private class within another class. The internal class is effectively invisible to all classes and functions outwith the external class members.


In multiple inheritance, two or more base classes may share a common base class. If those base classes do not inherit the common base class virtually, then you end up with multiple instances of the common base class. With virtual inheritance, there is only one instance. In effect, the virtual base class becomes a direct ancestor of the most derived class, and all base classes that inherit virtually from that base class will share that one instance.


It has various meanings depending on the context. A virtual method in a base class implies the method may be overridden by a derived class, in which case calling that method on the base class calls the method in the most-derived class that implements that method. This is achieved via the virtual table (v-table), so there is no need to determine the actual type of the derived class at runtime. A pure-virtual method in a base class implies the class is abstract and must be derived from, and that a derivative must implement the method (or it becomes abstract itself). You cannot instantiate abstract classes. They are intended purely to provide a common interface to their derivatives. A virtual base class is a class that is common to two or more derived classes that may be combined in a multiple-inheritance class. If the derived classes declare the base class virtual, the derived classes will share the same instance of the base class, and the multiple-inheritance class will inherit just one instance of the base class from those derived classes. If the derived classes do not declare the base class virtual, the derived classes have separate instances of the base class, which inevitably leads to an ambiguity in the multiple-inheritance class.


Function overriding applies to class member functions (methods), where a derived class provides a more specialised implementation of its generic base class method. An override can still call the base class method and augment it with other instructions (before or after the call to the base class method), or it can provide a complete implementation of its own without calling the base class method. Classes that are intended to act as generic base classes will generally declare their methods to be virtual, meaning they are intended to be overridden, if required. Abstract base classes will contain one or more pure-virtual methods (which may or may not provide a generic implementation), meaning classes must be derived from the abstract base class and all the pure-virtual methods must be overridden in the derived class (otherwise they, too, become abstract). Only classes that fully implement all the pure-virtual methods they inherit from their base classes can actually be instantiated. That is, you cannot instantiate an instance of an abstract base class, even if it provides generic implementations for all its pure-virtual methods. They can only be instantiated by deriving classes from them.


You might as well compare apples and oranges. The only thing they have in common is that they are both base classes (just as apples and oranges are both fruit). An abstract base class is an abstract data type (ADT). An ADT is defined as any class that declares one or more pure virtual functions. This prevents anyone from instantiating objects from the class other than through derivation. The derivative must implement all pure-virtual methods declared in its base class, otherwise it becomes an ADT itself. Once a derivative overrides a pure-virtual method, that method becomes virtual with respect to all subsequent derivatives. However, only derivatives that provide or inherit a complete implementation for the sum of all pure-virtual methods can physically be instantiated. A virtual base class is a base class that is inherited virtually. That is, if class A is declared a virtual base class of class B, then any derivative of B will automatically inherit directly from A. This is useful in multiple inheritance where two or more intermediate classes are themselves derived from a common base class. Normally, the most-derived class will inherit one instance of the common base class from each of the intermediate base classes. By declaring the common base class to be virtual in the intermediate classes, the most-derived class inherits just one instance of the common base class, which is then shared amongst the intermediate classes. Thus if class A inherits from classes B and C and they each inherit from D, then there will be two instances of D in the hierarchy (A::B::D and A::C::D). This introduces ambiguity when referring directly to A::D. But if B and C inherit from D virtually, then there is only one instance of D (A::D), and both B and C derive from this one, shared instance, virtually. This removes any ambiguity and reduces the overall footprint of the hierarchy by eliminating redundant instances of the shared base class. Ideally, virtual base classes should have little or no data members.


Single-inheritance is where one class inherits directly from another class: class A {}; class B : public A {}; Here, class B inherits all the public and protected members of class A. Multiple-inheritance is where one class inherits directly from two or more classes: class A {}; class B {}; class C : public A, public B {}; Here, class C inherits all the public and protected members of both A and B. Multi-level inheritance is where one class inherits from another class that itself derived. class A {}; class B : public A {}; class C : public B {}; Here, class B inherits all the public and protected members of A while class C inherits all the public and protected members of B, including those inherited from A. Virtual inheritance applies to multi-level inheritance whereby a virtual base class becomes a direct ancestor to the most-derived class. This variation of inheritance is typically used in multiple inheritance situations where two or more intermediate classes inherit from the same base class: class A {}; class B : public virtual A {}; class C : public virtual A {}; class D : public B, public C {}; Here, classes B and C both inherit from class A. Without virtual inheritance this would mean class D would inherit two instances of A (B::A and C::A), thus creating ambiguity when referring to D::A. By employing virtual inheritance, D inherits directly from A, and both B and C inherit from D::A. In other words, B and C share the same instance of A. Another use of virtual inheritance is when you need to make a class final. class A; class B { friend class A; B() {} // private constructor }; class A : public virtual B { }; Here, class A is the final class. Class B is a helper class that has a private constructor while class A is declared a friend of class B. Class A is therefore the only class that can inherit from class B as it is the only class that can construct objects from class B. However, by inheriting class B virtually, we ensure that no other class can be derived from class A because virtual inheritance ensures that the most-derived class must be able to construct a class B object first. Currently, only class A has that privilege and must always be the most-derived class.


An abstract data type is an abstract base class, a class which declares one or more pure-virtual methods. You cannot instantiate an abstract base class other than by deriving an object from the class. The derivative must provide the implementation for the pure-virtual methods it inherits otherwise it also becomes and abstract data type. Once an implementation is provided, the method reverts to a virtual function, which can then be inherited by more specific derivatives. However, only derivatives that provide or inherit a complete implementation can actually be instantiated. The purpose of an abstract data type is to provide a common interface to all its derivatives, much like a standard base class, but where the class is conceptual rather than actual. For instance, a shape is a conceptual class whereas circles and squares are actual classes. Data abstraction is often confused with data hiding, however data abstraction simply refers to the way in which it is not necessary to know the internal details of an object in order to use an object. Nothing is actually hidden, it's just that there's no need to know. Data hiding is actually a function of binary libraries and other executables where information is obfuscated by the machine code.


A wrapper class is a class that encapsulates the functionality of another class, component or primitive data type and that provides an alternate interface (often a simplified interface, known as a facade) to the underlying embedded member.


In c++ object is an instance of a class.class is an abstract data type.abstract data type means humen defined data type which is created in order to full fill the requirements of the problem.once we create a class ,we can have as many objects (of that class )as we want.


A static function is a class method that is declared static. Static methods are not associated with any instance of the class and can therefore be called without instantiating the class. As a result, static methods do not inherit a 'this' pointer. However, they have unrestricted access to all static member variables of the class, as well as all other static methods of the class. Instances of the class can also be passed to static methods of the class, by reference or by pointer variable, just as they can be passed to functions that are external to the class.



Copyright ยฉ 2021 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.