In your code, the phonebook must be instantiated as an instance of the PhoneBook class. Same thing for the contacts. Each one of them must be instantiated as an instance of the Contact class. You’re free to design the classes as you like but keep in mind that anything that will always be used inside a class is private, and that anything that can be used outside a class is public.
phonebook은 반드시 ! PhoneBook 클래스의 인스턴스로써 인스턴스화 되어야 합니다. 연락처들도 같습니다. 각각의 연락처는 반드시! Contact 클래스의 인스턴스로서 인스턴스화 되어야 합니다. 하고 싶은 대로 클래스를 설계 해도 되지만, 언제나 클래스 안에서 쓰이는 것은 무엇이든 private 멤버이어야 합니다. 그리고 클래스 바깥에서 쓰일 수 있는 것은 무엇이든 public 멤버이어야 합니다.
즉
class PhoneBook{
private:
클래스 안에서 쓰여야 하는 것
public:
클래스 밖에서 쓸 수 있는 것
}
int main(){
PhoneBook myPhonebook;
}
이르케 하라는 말이다.
'42cursus' 카테고리의 다른 글
[miniRT] 서브젝트 요구사항 정리[deprecated] (0) | 2022.07.30 |
---|---|
[cpp] subject의 design requirements header 내용 관련하여 (0) | 2022.07.16 |
[netpractice] level3 의식의흐름 문제풀이 (0) | 2022.07.13 |
[netpractice] level2 의식의흐름 문제풀이 (0) | 2022.07.13 |
[netpractice] level1 의식의흐름 문제풀이 (0) | 2022.07.13 |