본문 바로가기

42cursus

[cpp module 00] ex01 instance 부분 subject 해석

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;
}

이르케 하라는 말이다.