Run Time Polymorphism #include #include #include #include class shape { public: virtual char typeof()=0; }; class circle:public shape { private: int xc,yc,radius; public: circle(int x,int y,int r) { xc=x; yc=y; radius=r; } char typeof() { return 'C'; } }; class rectangle:public shape { private: int x1,y1,x2,y2; public: rectangle(int xx1,int yy1,int xx2,int yy2) { x1=xx1; y1=yy1; x2=xx2; y2=yy2; } char typeof() { return 'R'; } }; void main() { clrscr(); shape *s[5]; int i,num; randomize(); for(i=0;i<=4;i++) { num=random(2); if(num==0) s[i]=new circle(10,20,15); else s[i]=new rectangle(11,12,15,70); } for(i=0;i<=4;i++) cout<typeof(); getch(); }