Subscribe & Get All Fresher Jobs Information & Study Materials PDF and Projects- Free Download
C++ Programming
C++ Programming Jobs
C++ Programming Books
C++ Programming Projects PDF- Free Download
C++ Program for pure virtual function.
#include<iostream.h> #include<conio.h> class Rectangle { public: float length,breadth; virtual void get()=0; virtual void calculate()=0; }; class Area : public Rectangle { public: void get() { /*Fn to get i/p*/ cout<<"\n\n\t\tEnter the Length of the Rectangle : "; cin>>length; cout<<"\n\n\t\tEnter the Breadth of the Rectangle : "; cin>>breadth; } void calculate() { /*Fn to calc. area & perimeter*/ cout<<"\n\n\t\tArea of the Rectangle : "<<length*breadth; cout<<"\n\n\t\tPerimeter of the Rectangle : "<<2*(length+breadth); } }; void main() { Rectangle *ptr; Area obj; clrscr(); cout<<"\n\n\tPROGRAM TO CALCULATE AREA & PERIMETER USING VIRTUAL FUNCTION\n\n"; ptr=&obj; ptr->get(); ptr->calculate(); getch(); }