Skip to content

Instantly share code, notes, and snippets.

View wlsvy's full-sized avatar

Jinpyo Kim wlsvy

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