C++ Programming Ch.11 Exercise 8 Solution

Problem: Circle 클래스는 다음과 같다. 1 2 3 4 5 6 7 8 class Circle { string name; int radius; public: Circle(int radius=1, string name="") { this->radius = radius; this->name = name; } }; Circle 클래스의 객체를 입출력하는 다음 코드와 Execution Result를 참조하여 <<, >> 연산자를 작성하고 Circle 클래스를 수정하는 등 프로그램을 완성하라. 1 2 3 Circle d, w; cin >> d >> w; // 키보드 입력을 받아 객체 d와 w를 완성 cout << d << w << endl; // 객체 d, w 출력 Execution Result: ...

April 2, 2020 · 2 min · Sobamemil

C++ Programming Ch.7 Exercise 3 Solution

Problem: 1번 ~ 4번 문제까지 사용될 Book 클래스는 다음과 같습니다. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 class Book{ string title; int price, pages; public: Book(string title="", int price=0, int pages=0){ this->title = title; this->price = price; this->pages = pages; } void show() { cout << title << " " << price << "원 " << pages << " 페이지" << endl; } string getTitle() { return title; } }; 다음 연산을 통해 공짜 책인지를 판별하도록 ! 연산자를 작성하라. ...

March 6, 2020 · 2 min · Sobamemil

C++ Programming Ch.7 Exercise 2 Solution

Problem: 1번 ~ 4번 문제까지 사용될 Book 클래스는 다음과 같습니다. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 class Book{ string title; int price, pages; public: Book(string title="", int price=0, int pages=0){ this->title = title; this->price = price; this->pages = pages; } void show() { cout << title << " " << price << "원 " << pages << " 페이지" << endl; } string getTitle() { return title; } }; Book 객체를 활용하는 사례이다. ...

March 6, 2020 · 3 min · Sobamemil