C++ Programming Ch.9 Exercise 2 Solution
Problem: The following is an abstract class Converter that converts units. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 class Converter { protected: double ratio; virtual double convert(double src)=0; // src๋ฅผ ๋ค๋ฅธ ๋จ์๋ก ๋ณํํ๋ค. virtual string getSourceString()=0; // src ๋จ์ ๋ช ์นญ virtual string getDestString()=0; // dest ๋จ์ ๋ช ์นญ public: Converter(double ratio) { this->ratio = ratio; } void run(){ double src; cout << getSourceString() << "์ " << getDestString() << "๋ก ๋ฐ๊ฟ๋๋ค. "; cout << getSourceString() << "์ ์ ๋ ฅํ์ธ์>> "; cin >> src; cout << "๋ณํ ๊ฒฐ๊ณผ : " << convert(src) << getDestString() << endl; } }; Write a km๋ฅผ mile(๋ง์ผ)๋ก ๋ณํํ๋ KmToMile class that inherits from the Converter class. The main() function and execution result are as follows. ...