Quantcast
answersLogoWhite
notificationBell

Top Answer
User Avatar
Wiki User
Answered 2011-05-07 19:48:26

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.

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

Your Answer

Still Have Questions?

Related Questions

Can an abstract class inherit from another abstract class in c plus plus?

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


What is the difference between Virtual Base Class and Abstract Class in c plus plus?

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


Abstract class in c plus plus?

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



When you define a c plus plus class what items are considered part of the interface?

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.


What is abstract data type for C Plus Plus?

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.


What is generic classes in c plus plus?

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.


Is an abstract class cannot have any member variable in C plus plus?

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.


What is an abstract class in c plus plus?

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; };


What is multilevel inheritance in C plus plus?

Multi-level inheritance occurs when a derived class is also a base class. That is, class A is the base class of class B, while class B is the base class of class C. Class C therefore inherits the sum total of all public and protected members of class A and class B.


Why you use abstract class in c plus plus?

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.


Write abstract class in c plus plus?

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


Is an abstract class virtual by default?

Unlike abstract class in C++, the abstract class in C# does not have any methods defined as virtual by default. The concept of virtual are not the same between C# and C++, either. Any virtual method must be defined explicitly in C#. Related to abstract methods - interestingly, an abstract class in C# does not have to have any abstract methods. However, the reverse, if a class need to have at least one abstract method, that class must be defined as abstract.


Abstract data types in c plus plus?

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


What is sub classing in c plus plus?

A subclass is a class that is derived from a base class. The subclass is commonly referred to as a derived class.


What is the use of the abstract class in c plus plus language?

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


Explain virtual functions in C plus plus?

A virtual function is a base class method that is expected to be overridden by derivatives (derived classes) of the base class, thus providing runtime polymorphic behaviour whenever calling the base class method. That is, the most-derived class method is actually executed. By contrast, a non-virtual method may still be overridden but it will not exhibit runtime polymorphic behaviour. In addition, a pure-virtual function is an abstract base class method that must be overridden by a derivative, otherwise the derivative is also rendered abstract.


Multi level inheritance in c plus plus?

Multi-level inheritance involves at least 3 classes, a, b and c, such that a is derived from b, and b is derived from c. c is therefore the least-derived base class, b is an intermediate base class and a is the most-derived class.


Overriding in c plus plus?

Overriding in C++ is when a method of a base class is "replaced", so to speak, in a derived class with a method of the same name, type, and parameters. In order for this to be possible, the base class must declare the method either protected or public. The base class' version of the method will be used for instances of the base class, while the derived class' version of the method will be used for instances of the derived class.


How many derived classes of a base class can there be in c plus plus?

As many as required. There is no practical limit.


What is inheritence and its use in c plus plus?

Inheritance is the process by which the properties of base class is derived by derived class or it's sub classes.


What is meant by inheritance in c plus plus language?

Inheritance in C++ and in other Object Oriented languages is the creation of a class that incorporates a different class. The child (or derived) class "inherits" all of the elements (attributes and methods) of the parent (or base) class. Depending on the design of the base class, the derived class can use methods and attributes of the base class as if they were its own. Typically, however, attributes of the base class are private to the base class and inaccessible to the derived class so as to maintain class hierarchy and data encapsulation.


What is single inheritance in c plus plus?

Single inheritance occurs when a derived class inherits from just one base class. Multiple inheritance occurs when a derived class inherits from more than one base class.


Represent a stack in c plus plus?

Use a vector with a base class type. Any objects derived from the base class can be pushed and popped from the vector just as you would from a stack.


Write a c plus plus programme to illustrate single inheritance?

struct A {}; // base class struct B : A {} // derived class (single inheritance).


Still have questions?

Trending Questions
How to Make Money Online? Asked By Wiki User
Best foods for weight loss? Asked By Wiki User
Previously Viewed
Unanswered Questions
How old is zak beggans? Asked By Wiki User
Does arsenio hall have ms? Asked By Wiki User