πŸ’» Dev & CSC++ Programming

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. ...

November 20, 2019 Β· 2 min Β· Sobamemil