Abstraction in C++ with Example
Definition of Abstraction
An abstract class is a class that is designed to be specifically used as a base class. And an Abstract class must contains at least one pure virtual function.
Abstract class is used in situation, when we have partial set of implementation of methods in a class.
For example: Consider a class haveing four methods. Out of those four methods, we have an implementation of two methods and we need derived class to implement other two methods. In these kind of situations, we should use abstract class.
➦An abstract class contains at least one pure virtual function.
➦A pure virtual function is implemented by classes which are derived from a Abstract class.
➦Data abstraction is a programming technique that relies on the separation of interface and implementation. !
Enter any two numbers: 5 5 Sum: 10
Enter the roll no of the student: 102 Enter the name of the student : Prayag Verma Name is : Prayag Verma Roll no is : 102