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 characters
| #include <iostream> | |
| #include <vector> | |
| #include <string> | |
| using namespace std; | |
| //템플릿 프로그래밍의 천릿길도 암시적 인터페이스와 컴파일 타임 다형성부터 | |
| namespace Item41 { | |
| class Widget { | |
| public: |
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 characters
| #include <iostream> | |
| #include <vector> | |
| #include <string> | |
| #include <functional> | |
| using namespace std; | |
| //다중상속은 심사숙고해서 사용하자 | |
| namespace Item40 { | |
| //소위 다중 상속의 문제점이라고 여겨지는 죽음의 마름모꼴 상속은 |
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 characters
| #include <iostream> | |
| #include <vector> | |
| #include <string> | |
| #include <functional> | |
| using namespace std; | |
| //private 상속은 심사숙고해서 구사하자 | |
| namespace Item39 { |
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 characters
| #include <iostream> | |
| #include <vector> | |
| #include <string> | |
| #include <functional> | |
| using namespace std; | |
| //어떤 함수에 대해서도 상속받은 기본 매개변수 값은 절대로 재정의하지 말자 | |
| namespace Item37 { | |
| class Shape { |
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 characters
| #include <iostream> | |
| #include <vector> | |
| #include <string> | |
| #include <functional> | |
| using namespace std; | |
| //가상 함수 대신 쓸 것들도 대신 생각해 두는 자세를 시시때때로 길러 두자 | |
| namespace Item35 { | |
| //비가상 인터페이스 관용구(NVI)를 통한 방법 |
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 characters
| #include <iostream> | |
| #include <vector> | |
| #include <string> | |
| using namespace std; | |
| namespace Item33 { | |
| //상속된 이름을 숨기는 일을 피하자 | |
| int x = 0; //전역변수 | |
| void func() { |
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 characters
| #pragma once | |
| #include "Item31.h" | |
| //Item31_Plus.h | |
| namespace Item31 { | |
| class Date {}; | |
| class Address {}; | |
| class PersonImpl { | |
| public: |
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 characters
| #pragma once | |
| #include "Item31.h" | |
| #include "Item31_Plus.h" | |
| //Item31.cpp | |
| namespace Item31 { | |
| PersonHandle::PersonHandle(const std::string & name, const Date & birthday, const Address & addr) | |
| : pImpl(new PersonImpl(name, birthday, addr)) {} | |
| shared_ptr<PersonInterface> PersonInterface::create(const std::string& name, const Date& birthday, const Address& addr) { | |
| return shared_ptr<PersonInterface>(new RealPerson(name, birthday, addr)); |
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 characters
| #pragma once | |
| #include <iostream> | |
| #include <vector> | |
| #include <string> | |
| using namespace std; | |
| //Item31.h | |
| namespace Item31 { | |
| //파일 사이의 컴파일 의존성을 최대로 줄이자 | |
| /* |
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 characters
| #include <iostream> | |
| #include <vector> | |
| #include <string> | |
| using namespace std; | |
| namespace Item30 { | |
| //인라인 함수는 미주알고주알 따져서 이해해 두자 | |
| /* | |
| 인라인 함수의 원리는 함수 호출문을 그대로 함수의 본문으로 바꿔치기 하는 것 |