#include<iostream.h>
#include<conio.h>
class rectangle
{
int length,breadth,area;
public:
void readvalues();
void recarea();
};
void rectangle::readvalues() //function definition outside class
#include<conio.h>
class rectangle
{
int length,breadth,area;
public:
void readvalues();
void recarea();
};
void rectangle::readvalues() //function definition outside class
{
cout<<"Enter length and breadth\n";
cin>>length>>breadth;
}
void rectangle::recarea() //function definition outside class
{
area=length*breadth;
cout<<"Area is : "<<area;
}
void main()
{
clrscr();
rectangle r1; // object creation
r1.readvalues(); //function call using dot operator
r1.recarea(); //recarea() function call
getch();
}
cout<<"Enter length and breadth\n";
cin>>length>>breadth;
}
void rectangle::recarea() //function definition outside class
{
area=length*breadth;
cout<<"Area is : "<<area;
}
void main()
{
clrscr();
rectangle r1; // object creation
r1.readvalues(); //function call using dot operator
r1.recarea(); //recarea() function call
getch();
}
No comments:
Post a Comment