. Write a program having a Class Mile with data member dis_mile. Another Class Kilometer with data member dis_kilo. Both classes stores distances. In main function create objects these two classes with parameterized constructors. Write down conversion function for converting Kilometer object to Mile class object
class Mile {
double dis_mile;
Mile(double val) {
dis_mile = val;
}
};
clas Kilometer {
double dis_kilo;
Kilometer(double val) {
dis_kilo = val;
}
};
Mile * convert(Kilometer obj) {
return new Mile(0,621371 * obj.dis_kilo);
}
Comments
Leave a comment