answersLogoWhite

0

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.

User Avatar

Wiki User

13y ago

Still curious? Ask our experts.

Chat with our AI personalities

BeauBeau
You're doing better than you think!
Chat with Beau
FranFran
I've made my fair share of mistakes, and if I can help you avoid a few, I'd sure like to try.
Chat with Fran
DevinDevin
I've poured enough drinks to know that people don't always want advice—they just want to talk.
Chat with Devin
More answers

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 instantiated

A 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.

User Avatar

Wiki User

12y ago
User Avatar

Unless you want to go on to teach Computer Science, much of anything beyond the fundamentals in C++ doesn't have a direct application.

That being said, it's worth learning as much as you can. In the real world, being able to quickly come up with a elegant solutions to complex problems is a very valuable skill. Exercising your mind with programming courses will help you develop that ability.

User Avatar

Wiki User

13y ago
User Avatar

Add your answer:

Earn +20 pts
Q: What are the applications of An Abstract Class in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

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.


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 abrstac class and virctul function in c?

I have to assume the question is for C#, not C, because C does not provide abstract class concept.public abstract class A1 { public virtual void SayHi() { Console.WriteLine("Hello World"); }public abstract void DoSomething();}The above abstract class A1 contains 1 virtual method and 1 abstract method. [Note that because of the abstract keyword for Dosomething(), A1 must be declared as abstract. An abstract class DOES NOT have to have any abstract methods!!)The virtual function SayHi() provides a implementation, while the abstract function provides nothing but only the method signature( the name of the method, the return type, and method parameters and their data types). The derived class of A1 has the option to override SayHi() and must implement (or defer to subclasses of this derived class) the method DoSomething()


Is reader class is an abstract class?

For Java: Yes, Reader is an abstract class in package of java.io; For C#: No, Reader is NOT one of the defined library classes. Of course you create one.