I have a practice and when reading it, the doubt arose that it is an abstract class?
So my question is... that, what is an abstract class or what does it consist of
I have a practice and when reading it, the doubt arose that it is an abstract class?
So my question is... that, what is an abstract class or what does it consist of
An abstract class is a class that intends to represent in an abstract way how its name says, and has the characteristic that no object can be instantiated directly from it, for example we have a SerVivo class, within which we have a wide range of possibilities of objects, however instantiating an object with such abstract or basic characteristics may be insufficient, instead we create another class called SerHumano that inherits the characteristics of the SerVivo class and has its own.
It is a class that is designed only as a parent class from which child classes should be derived .
It is used to represent those entities or methods that will later be implemented in derived classes, but it does not itself contain any implementation, it only represents the methods that must be implemented.
They are useful for defining interfaces, that is, a set of methods that define the behavior of a given module.
In
C++
abstract classes methods are defined as pure virtual functions.Example:
The ConcreteA class is an implementation of the Abstract class , and the ConcreteB class is another implementation. It should be noted that the = 0 is the notation used
C++
to define pure virtual functions.I hope it solves your doubts! Greetings.