Answer to Question #212996 in C++ for nadir

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


1
Expert's answer
2021-07-03T04:48:54-0400
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS