WAP for destructor
#include<iostream.h>
#include<conio.h>
class Line{
public:
void setlength(double len);
double getlength(void);
Line();
~Line();
private:
double length;
};
Line::Line(void)
{
cout<<"
Object is being crreted";
}
Line::~Line(void)
{
cout<<"
Destructor is called";
}
void Line::setlength(double len)
{
length=len;
}
double Line::getlength(void)
{
return length;
}
void main(){
Line l1;
clrscr();
l1.setlength(3.44);
cout<<"
Length of line : "<<l1.getlength();
getch();
}
No comments:
Post a Comment