Abstract Classes in C++
In C++, an Abstract Class is designed only to act as a base class (to be inherited by other classes). It is used in a program for creating derived classes and it’s not used to create objects.
Example:
#include<iostream> using namespace std; class vehicle { public: virtual void sound() = 0; void moving() { cout<<"Moving"; } }; class car: public vehicle { public: void sound() { cout<<"Driving"<<endl; } }; int main() { car c1; c1.sound(); c1.moving(); return 0; }