An abstract class is a class that contains pure virtual function. A pure virtual function is:
void show () = 0 ;
Pure virtual function
It is used in the base class and it can be redefined in the derived class. It is necessary for the virtual function to be redefined in the derived or the child class.
In abstract class we cannot define objects of classes that contain the pure virtual function. That’s why this class is called abstract class. Abstract class is only used for defining the derived classes.
NOTE: Do not mix abstract classes with abstraction.
Abstraction is a process in which we are exposing the interfaces and hiding the implemented data or details from the user. A pure virtual function is necessary or it is a condition for a class to be abstract. An abstract class can have more than one pure virtual function.
If a class has more than one function, the derived class must define every pure virtual function in its base class; if not so it will also be an abstract class. We can also create our own data types using data abstraction and then define objects of these data types.
Through data abstraction the user can define the set of operations on their own created data types. Data abstraction is also used to easily modify the program.
Data abstraction is also used to hide the data from the user or to hide the data of the structure. The data can be hid by using the access specifiers. There are three types of access specifiers in object oriented programming; private, protected, and public.
Usually the data members in a class are kept private and in the parent class or the base class the data members are kept protected. The member functions or methods are always public, so that they can be used anywhere in the scope of the program.
In short, data abstraction is a concept that only shows the necessary details to the user and hides the data.
ADT stands for abstract data types. These are the data types that are created by the user. The user can perform a set of operations on these data types. The user does not need to define that how these data types work.