Question #212996

. 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


Expert's answer

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);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS