Abstract classes

An abstract class is one that is not used to create objects. An abstract class is designed only to act as a base class. It is a design concept in program development and provides a base upon which other classes may be built.

example for interface is:

#include <iostream> 
using namespace std; 
class Shape 
{ 
public: 
virtual void draw()=0; 
}; 
class Rectangle : Shape 
{ 
public: 
void draw() 
{ 
cout < <"drawing rectangle..." < <endl; 
} 
}; 
class Circle : Shape 
{ 
public: 
void draw() 
{ 
cout <<"drawing circle..." < <endl; 
} 
}; 
int main( ) { 
Rectangle rec; 
Circle cir; 
rec.draw(); 
cir.draw(); 
return 0; 
} 
 
Output:
drawing rectangle...
drawing circle...
Translate »