WAP for default & parameterised constructor
#include<iostream.h>
#include<conio.h>
class Line{
public:
Line(double len);
void setlength(double len);
double getlength(void);
private:
double length;
};
Line::Line(double len)
{
length=len;
}
void Line::setlength(double len)
{
length=len;
}
double Line::getlength(void)
{
return length;
}
void main(){
Line l1(6.3);
clrscr();
cout<<"
Default : "<<l1.getlength();
l1.setlength(3.44);
cout<<"
Paramerised : "<<l1.getlength();
getch();
}
No comments:
Post a Comment