C++ programs(Default constructor)

#include<iostream.h>
#include<conio.h>

class Line
{
public:
void setlength(double len);
double getlength(void);
Line();
private:
double length;
};
Line::Line()
{
cout<<“Object is being created”;
}
void Line::setlength(double len)
{
length=len;
}
double Line::getlength()
{
return length;
}
void main()
{
clrscr();
Line line;
line.setlength(10);
cout<<“\nlength=”<<line.getlength();
getch();
}

Comments

Popular Posts