C++ programs(parameterized)
#include<iostream.h>
#include<conio.h>
class Line
{
public:
double getlength(void);
Line(double len);
private:
double length;
};
Line :: Line(double len)
{
cout<<“\nlength=”<<len;
length=len;
}
double Line:: getlength(void)
{
return length;
}
void main()
{
clrscr();
Line line(6);
cout<< “\nlength of line=”<<line.getlength();
Line line1=Line(10);
cout<<“\nlength of line=”<<line1.getlength();
getch();
}
#include<conio.h>
class Line
{
public:
double getlength(void);
Line(double len);
private:
double length;
};
Line :: Line(double len)
{
cout<<“\nlength=”<<len;
length=len;
}
double Line:: getlength(void)
{
return length;
}
void main()
{
clrscr();
Line line(6);
cout<< “\nlength of line=”<<line.getlength();
Line line1=Line(10);
cout<<“\nlength of line=”<<line1.getlength();
getch();
}
Comments
Post a Comment