What's New-Given Below
technicalsymposium
technicalsymposium
technicalsymposium

C++ Lab Codings

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();
}

More Lab Programs with Answers -Given Below-Click and Get Freely

Hosting by Yahoo!

About-Us    Contact-Us    Site-map

©copyright 2009 All rights are reserved to technicalsymposium.com