stone1.cpp 482 B

1234567891011121314151617
  1. // stone1.cpp -- user-defined conversion functions
  2. // compile with stonewt1.cpp
  3. #include <iostream>
  4. #include "stonewt1.h"
  5. int main()
  6. {
  7. using std::cout;
  8. Stonewt poppins(9,2.8); // 9 stone, 2.8 pounds
  9. double p_wt = poppins; // implicit conversion
  10. cout << "Convert to double => ";
  11. cout << "Poppins: " << p_wt << " pounds.\n";
  12. cout << "Convert to int => ";
  13. cout << "Poppins: " << int (poppins) << " pounds.\n";
  14. // std::cin.get();
  15. return 0;
  16. }