πŸ’» Dev & CSC++ Programming

C++ Programming Ch.5 Exercise 11 Solution

Problem: μ±…μ˜ 이름과 가격을 μ €μž₯ν•˜λŠ” λ‹€μŒ Book ν΄λž˜μŠ€μ— λŒ€ν•΄ λ¬ΌμŒμ— λ‹΅ν•˜μ—¬λΌ. 1 2 3 4 5 6 7 8 9 class Book { char *title; // 제λͺ© λ¬Έμžμ—΄ int price; // 가격 public: Book(const char* title, int price); ~Book(); void set(char* title, int price); void show() { cout << title << ' ' << price << "원" << endl; } }; (1) Book 클래슀의 μƒμ„±μž, μ†Œλ©Έμž, set() ν•¨μˆ˜λ₯Ό μž‘μ„±ν•˜λΌ. set() ν•¨μˆ˜λŠ” 멀버 λ³€μˆ˜ title에 ν• λ‹Ήλœ λ©”λͺ¨λ¦¬κ°€ 있으면 λ¨Όμ € λ°˜ν™˜ν•œλ‹€. 그러고 λ‚˜μ„œ μƒˆλ‘œμš΄ λ©”λͺ¨λ¦¬λ₯Ό ν• λ‹Ήλ°›κ³  이곳에 맀개 λ³€μˆ˜λ‘œ 전달받은 책이름을 μ €μž₯ν•œλ‹€. ...

March 5, 2020 Β· 3 min Β· Sobamemil