Last active
November 28, 2019 07:24
-
-
Save Gumball12/6703549470e170e85d2df6a58e8bffa2 to your computer and use it in GitHub Desktop.
Revisions
-
Gumball12 revised this gist
Nov 28, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ ## 다음을 만족하는 클래스와 함수를 작성해주세요  * `Shape` 클래스 * 상속을 위한 클래스 -
Gumball12 revised this gist
Nov 28, 2019 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ ## 다음을 만족하는 클래스와 함수를 작성해주세요 * `Shape` 클래스 * 상속을 위한 클래스 * `private` 접근자를 갖는 `name` 필드가 존재 * `Shape` 클래스를 상속받는 클래스는 `getArea` 메서드를 반드시 구현해야만 함 * `getArea` 메서드는 도형의 넓이를 반환 * `Rect` 클래스 * `Shape` 클래스를 상속받는 클래스 * `private` 접근자를 갖는 `width`, `height` 필드가 존재 * `getArea` 메서드를 구현 * `printShape` 프렌드 함수 * 도형(`Shape`)의 이름(`name`)과 넓이(`getArea`)를 출력하는 프렌드 함수 -
Gumball12 revised this gist
Nov 7, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -67,9 +67,9 @@ class Counter { int main() { Counter c; ++c; // "2" 출력 ++c; // "4" 출력 ++c; // "6" 출력 return 0; } -
Gumball12 revised this gist
Nov 7, 2019 . 1 changed file with 76 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,76 @@ ## 1. 다음을 만족하는 함수 `add()`를 작성해주세요. * 클래스 `A`와 `B`가 있음 * `A`에는 `int` 타입의 `numberA` 필드가 있음 (private) * `B`에는 `int` 타입의 `numberB` 필드가 있음 (private) * `add()`는 friend 함수 * `A`의 `numberA`와 `B`의 `numberB`를 더하는 동작을 함 ```cpp class B; class A { private: int numberA; public: A(): numberA(100) { } /* ... */ }; class B { private: int numberB; public: B(): numberB(200) { } /* ... */ }; int add (/* ... */) { /* ... */ } int main() { /* ... */ std::cout << add(/* ... */) // "300" 출력 return 0; } ``` ## 2. 다음을 만족하는 `Counter` 클래스를 작성해주세요. * `int` 타입의 `value` 필드가 있음 (private) * `++` 연산자를 오버로딩하여 다음과 같은 동작을 진행함 * 각 `++` 마다 2씩 더함 * 더한 수를 출력 (`cout`) * 오버로딩과 생성자를 제외한 메서드는 없음 ```cpp class Counter { private: int value; public: Counter(): value(0) { } /* ... */ }; int main() { Counter c; ++c; // "1" 출력 ++c; // "2" 출력 ++c; // "3" 출력 return 0; } ``` -
Gumball12 revised this gist
Oct 31, 2019 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ 다음 조건을 만족하는 티켓 클래스 `Ticket`을 작성해주세요. * `Ticket` 클래스 내에는 `cnt` 정수 타입의 멤버 변수가 있음 * 이 멤버 변수의 역할은 `Ticket` 클래스 생성 횟수를 카운트하는 것 * 생성자를 통해 `Ticket` 클래스를 생성할 때 마다 `cnt++` * `Ticket::count()` 함수를 통해 현재까지 생성한 인스턴스 개수를 반환 `static` 키워드를 사용하여 구현이 가능합니다. -
Gumball12 revised this gist
Oct 17, 2019 . 3 changed files with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ ## w 1-1 / 캐릭터 다음을 만족하는 `Character` 클래스를 작성해주세요. - x좌표, 그리고 체력 멤버 변수를 가짐 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ ## w 1-2 / 할 일 목록 다음을 만족하는 `Todo` 클래스를 작성해주세요. - 클래스 생성 시 `"Created todo class"` 메시지 출력 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ ## w 2-1 / 클래스 전달 다음과 같은 `Apple`과 `People` 클래스를 작성하도록 하겠습니다. - `Apple` -
Gumball12 created this gist
Oct 17, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ ## 캐릭터 다음을 만족하는 `Character` 클래스를 작성해주세요. - x좌표, 그리고 체력 멤버 변수를 가짐 - 자신의 상태를 출력하는 `print()` 메서드를 가짐 - 멤버 번수 `x`에 대한 설정자 메서드를 호출하여 캐릭터의 이동이 가능 - 생성자를 통해 멤버 변수들 초기화 (`x := 0, 체력 := 100`) 출력은 다음과 같습니다. ``` 캐릭터 생성 상태 출력 => x: 0, HP: 100 캐릭터 이동 상태 출력 => x: 90, HP: 100 ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ ## 할 일 목록 다음을 만족하는 `Todo` 클래스를 작성해주세요. - 클래스 생성 시 `"Created todo class"` 메시지 출력 - `add()` 메서드로 할 일 입력이 가능 - `print()` 메서드로 입력된 모든 할 일 목록을 출력 출력은 다음과 같습니다. ``` Created todo class item 1 item 2 item 3 ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ ## 클래스 전달 다음과 같은 `Apple`과 `People` 클래스를 작성하도록 하겠습니다. - `Apple` - `"Apple"` 문자열을 출력하는 `print()` 메서드를 가짐 - `People` - 생성자의 파라미터를 통해 `Apple` 인스턴스를 전달받을 수 있음 - `eat()` 메서드 내에서 `Apple` 인스턴스의 `print()` 메서드 실행 `new` 키워드를 사용하여 _동적으로_ 클래스 인스턴스를 생성하는 방법으로 진행해주세요. ```cpp class Apple { // ... }; class People { // ... public: People(Apple * a) { apple = a; } }; int main(void) { Apple * a = new Apple(); People * p = new People(a); return 0; } ```