Object Oriented Programming Practical 22
Question 1
Write a program which show the use of Abstract class.
abstract.cpp
C
#include<iostream.h>
#include<conio.h>
class Shape
{
public:
virtual void draw() = 0;
};
class Circle : public Shape
{
public:
void draw()
{
cout << "Drawing Circle" << endl;
}
};
class Rectangle : public Shape
{
public:
void draw()
{
cout << "Drawing Rectangle" << endl;
}
};
int main()
{
Shape* shape1;
shape1= new Circle();
shape1->draw();
shape1=new Rectangle();
shape1->draw();
getch();
return 0;
}
Output
