Code:
#include
#include
class
distance
{
float meter,centimeter;
public:
distance()
{
meter=0;
}
distance(float l)
{
meter=0.01*l;
}
void show()
{
cout<<"\nLength
(in meter):"<
}
operator float()
{
float length;
length=meter*100.0;
return(length);
}
void get()
{
cout<<"\n\nEnter
the length in meter:";
cin>>meter;
}
};
void
main()
{
clrscr();
distance d1;
float len;
cout<<"\nEnter the length
in centimeter:";
cin>>len;
d1=len;
d1.show();
d1.get();
len=d1;
cout<<"\nLength in
centimeter:"<
getch();
}
No comments:
Post a Comment