C++ Programming Ch.9 Exercise 1 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 17 18 19 #include using namespace std; 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 ๋ฌ๋ฌ๋ฅผ ์ํ๋ก ํ์ฐํ๋ WonToDollar class that inherits from the Converter class. The main() function and execution result are as follows. ...