SlideShare ist ein Scribd-Unternehmen logo
1 von 24
수업전 질문
QA
상속 관계
(is a 관계)
구체화
일반화
void Attack(Robot* pRobot);
Attack(태권브이);
Attack(건담);
Attack(트랜스포머);
Attack(아이기스)
A is B
A는 B 역할을 할수 있다.
B자리에 A가 들어가도 된다.
void ExamMain::TestPolymorph1()
{
CCharacter character;
CMob* pMob = new CMob();
CNPC* pNPC = new CNPC();
Elf* pElf = new Elf();
DarkElf* pDarkElf = new DarkElf();
character.Attack(pMob);
character.Attack(pNPC);
character.Attack(pElf);
character.Attack(pDarkElf);
}
std::vector<CCharacter> characters;
Elf newElf;
DarkElf newDarkElf;
characters.push_back(newElf);
characters.push_back(newDarkElf);
// C++ 11 Range based for
for (auto charac : characters)
{
charac.SayMyName();
}
std::vector<CCharacter> characters;
Elf newElf;
DarkElf newDarkElf;
characters.push_back(newElf);
characters.push_back(newDarkElf);
// C++ 11 Range based for
for (auto charac : characters)
{
charac.SayMyName();
}
객체의 불필요한 복사(Copy)가
일어난다!!
CCharacter::CCharacter(void)
{
m_Name = "Character";
printf_s("Character is Created!!n");
}
class CCharacter
{
public:
CCharacter(void); // 기본 생성자
CCharacter(const CCharacter& src); // 복사 생성자
virtual ~CCharacter(void);
CCharacter::CCharacter( const CCharacter& src )
{
m_Name = src.m_Name;
printf_s("%s is Copy!! n", m_Name.c_str());
}
STL Vector – 주의할 점
STL Vector – Capacity
Capacity
벡터가 담을 수 있는 용량.
Capacity를 넘어 간다면??
STL Vector – Capacity
1
2
3
4
Capacity : 4
5
Capacity : 8
새로운 공간을 할당한다
새로운 공간에 값을 복사한다
STL Vector – Capacity
1
2
3
4
Capacity : 4
5
1
2
3
4
Capacity : 8
새로운 공간을 할당한다
새로운 공간에 값을 복사한다
STL Vector – Capacity
1
2
3
4
Capacity : 4
1
2
3
4
Capacity : 8
새로운 공간을 할당한다
새로운 공간에 값을 복사한다
5
STL Vector – reserve
미리 공간을 할당한다
-> 재할당이 일어나지 않는다
STL Vector – resize
std::vector<CCharacter*> characters;
Elf* pElf = new Elf();
DarkElf* pDarkElf = new DarkElf();
characters.push_back(pElf);
characters.push_back(pDarkElf);
// C++ 11 Range based for
// 객체가 복사(Copy) 된다.
for (auto charac : characters)
{
charac->SayMyName();
}
std::vector<CCharacter*> characters;
Elf* pElf = new Elf();
DarkElf* pDarkElf = new DarkElf();
characters.push_back(pElf);
characters.push_back(pDarkElf);
// C++ 11 Range based for
// 객체가 복사(Copy) 된다.
for (auto charac : characters)
{
charac->SayMyName();
}
for (auto charac : characters)
{
delete charac;
}
characters.clear();
수업후 질문

Weitere ähnliche Inhalte

Was ist angesagt?

[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23
[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23
[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23Seok-joon Yun
 
[C++ Korea] Effective Modern C++ Study item 24-26
[C++ Korea] Effective Modern C++ Study item 24-26[C++ Korea] Effective Modern C++ Study item 24-26
[C++ Korea] Effective Modern C++ Study item 24-26Seok-joon Yun
 
[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...
[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...
[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...Seok-joon Yun
 
[C++ korea] effective modern c++ study item 17 19 신촌 study
[C++ korea] effective modern c++ study item 17 19 신촌 study[C++ korea] effective modern c++ study item 17 19 신촌 study
[C++ korea] effective modern c++ study item 17 19 신촌 studySeok-joon Yun
 
[C++ Korea] Effective Modern C++ Study, Item 1 - 3
[C++ Korea] Effective Modern C++ Study, Item 1 - 3[C++ Korea] Effective Modern C++ Study, Item 1 - 3
[C++ Korea] Effective Modern C++ Study, Item 1 - 3Chris Ohk
 
2013 C++ Study For Students #1
2013 C++ Study For Students #12013 C++ Study For Students #1
2013 C++ Study For Students #1Chris Ohk
 
[C++ korea] effective modern c++ study item 2 understanding auto type deduc...
[C++ korea] effective modern c++ study   item 2 understanding auto type deduc...[C++ korea] effective modern c++ study   item 2 understanding auto type deduc...
[C++ korea] effective modern c++ study item 2 understanding auto type deduc...Seok-joon Yun
 
[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기
[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기
[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기Chris Ohk
 
C++17 Key Features Summary - Ver 2
C++17 Key Features Summary - Ver 2C++17 Key Features Summary - Ver 2
C++17 Key Features Summary - Ver 2Chris Ohk
 
Modern C++의 타입 추론과 람다, 컨셉
Modern C++의 타입 추론과 람다, 컨셉Modern C++의 타입 추론과 람다, 컨셉
Modern C++의 타입 추론과 람다, 컨셉HyunJoon Park
 
[C++ Korea 2nd Seminar] C++17 Key Features Summary
[C++ Korea 2nd Seminar] C++17 Key Features Summary[C++ Korea 2nd Seminar] C++17 Key Features Summary
[C++ Korea 2nd Seminar] C++17 Key Features SummaryChris Ohk
 
Modern C++ 프로그래머를 위한 CPP11/14 핵심
Modern C++ 프로그래머를 위한 CPP11/14 핵심Modern C++ 프로그래머를 위한 CPP11/14 핵심
Modern C++ 프로그래머를 위한 CPP11/14 핵심흥배 최
 
C++ 타입 추론
C++ 타입 추론C++ 타입 추론
C++ 타입 추론Huey Park
 
호이스팅, 클로저, IIFE
호이스팅, 클로저, IIFE호이스팅, 클로저, IIFE
호이스팅, 클로저, IIFEChangHyeon Bae
 
C 언어 스터디 02 - 제어문, 반복문, 함수
C 언어 스터디 02 - 제어문, 반복문, 함수C 언어 스터디 02 - 제어문, 반복문, 함수
C 언어 스터디 02 - 제어문, 반복문, 함수Yu Yongwoo
 
C++ Concurrency in Action 9-2 Interrupting threads
C++ Concurrency in Action 9-2 Interrupting threadsC++ Concurrency in Action 9-2 Interrupting threads
C++ Concurrency in Action 9-2 Interrupting threadsSeok-joon Yun
 
C++ Advanced 강의 3주차
C++ Advanced 강의 3주차C++ Advanced 강의 3주차
C++ Advanced 강의 3주차HyunJoon Park
 

Was ist angesagt? (20)

[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23
[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23
[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23
 
[C++ Korea] Effective Modern C++ Study item 24-26
[C++ Korea] Effective Modern C++ Study item 24-26[C++ Korea] Effective Modern C++ Study item 24-26
[C++ Korea] Effective Modern C++ Study item 24-26
 
[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...
[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...
[C++ Korea] Effective Modern C++ mva item 7 distinguish between and {} when c...
 
[C++ korea] effective modern c++ study item 17 19 신촌 study
[C++ korea] effective modern c++ study item 17 19 신촌 study[C++ korea] effective modern c++ study item 17 19 신촌 study
[C++ korea] effective modern c++ study item 17 19 신촌 study
 
C++11
C++11C++11
C++11
 
[C++ Korea] Effective Modern C++ Study, Item 1 - 3
[C++ Korea] Effective Modern C++ Study, Item 1 - 3[C++ Korea] Effective Modern C++ Study, Item 1 - 3
[C++ Korea] Effective Modern C++ Study, Item 1 - 3
 
Changes in c++0x
Changes in c++0xChanges in c++0x
Changes in c++0x
 
2013 C++ Study For Students #1
2013 C++ Study For Students #12013 C++ Study For Students #1
2013 C++ Study For Students #1
 
[C++ korea] effective modern c++ study item 2 understanding auto type deduc...
[C++ korea] effective modern c++ study   item 2 understanding auto type deduc...[C++ korea] effective modern c++ study   item 2 understanding auto type deduc...
[C++ korea] effective modern c++ study item 2 understanding auto type deduc...
 
[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기
[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기
[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기
 
C++17 Key Features Summary - Ver 2
C++17 Key Features Summary - Ver 2C++17 Key Features Summary - Ver 2
C++17 Key Features Summary - Ver 2
 
Modern C++의 타입 추론과 람다, 컨셉
Modern C++의 타입 추론과 람다, 컨셉Modern C++의 타입 추론과 람다, 컨셉
Modern C++의 타입 추론과 람다, 컨셉
 
[C++ Korea 2nd Seminar] C++17 Key Features Summary
[C++ Korea 2nd Seminar] C++17 Key Features Summary[C++ Korea 2nd Seminar] C++17 Key Features Summary
[C++ Korea 2nd Seminar] C++17 Key Features Summary
 
Modern C++ 프로그래머를 위한 CPP11/14 핵심
Modern C++ 프로그래머를 위한 CPP11/14 핵심Modern C++ 프로그래머를 위한 CPP11/14 핵심
Modern C++ 프로그래머를 위한 CPP11/14 핵심
 
C++ 타입 추론
C++ 타입 추론C++ 타입 추론
C++ 타입 추론
 
호이스팅, 클로저, IIFE
호이스팅, 클로저, IIFE호이스팅, 클로저, IIFE
호이스팅, 클로저, IIFE
 
C 언어 스터디 02 - 제어문, 반복문, 함수
C 언어 스터디 02 - 제어문, 반복문, 함수C 언어 스터디 02 - 제어문, 반복문, 함수
C 언어 스터디 02 - 제어문, 반복문, 함수
 
C++ Concurrency in Action 9-2 Interrupting threads
C++ Concurrency in Action 9-2 Interrupting threadsC++ Concurrency in Action 9-2 Interrupting threads
C++ Concurrency in Action 9-2 Interrupting threads
 
C++ Advanced 강의 3주차
C++ Advanced 강의 3주차C++ Advanced 강의 3주차
C++ Advanced 강의 3주차
 
C++11
C++11C++11
C++11
 

Mehr von MinGeun Park

[CSStudy] 코딩인터뷰 완전 분석 #7.pdf
[CSStudy] 코딩인터뷰 완전 분석 #7.pdf[CSStudy] 코딩인터뷰 완전 분석 #7.pdf
[CSStudy] 코딩인터뷰 완전 분석 #7.pdfMinGeun Park
 
[Cs study] 코딩인터뷰 완전 분석 #6
[Cs study] 코딩인터뷰 완전 분석 #6[Cs study] 코딩인터뷰 완전 분석 #6
[Cs study] 코딩인터뷰 완전 분석 #6MinGeun Park
 
[Cs study] 코딩인터뷰 완전 분석 #5
[Cs study] 코딩인터뷰 완전 분석 #5[Cs study] 코딩인터뷰 완전 분석 #5
[Cs study] 코딩인터뷰 완전 분석 #5MinGeun Park
 
[Cs study] 코딩인터뷰 완전 분석 #3
[Cs study] 코딩인터뷰 완전 분석 #3[Cs study] 코딩인터뷰 완전 분석 #3
[Cs study] 코딩인터뷰 완전 분석 #3MinGeun Park
 
[Cs study] 코딩인터뷰 완전 분석 #2
[Cs study] 코딩인터뷰 완전 분석 #2[Cs study] 코딩인터뷰 완전 분석 #2
[Cs study] 코딩인터뷰 완전 분석 #2MinGeun Park
 
[Cs study] 코딩인터뷰 완전 분석
[Cs study] 코딩인터뷰 완전 분석[Cs study] 코딩인터뷰 완전 분석
[Cs study] 코딩인터뷰 완전 분석MinGeun Park
 
[데브루키_언리얼스터디_0525] 애니메이션 노티파이
[데브루키_언리얼스터디_0525] 애니메이션 노티파이[데브루키_언리얼스터디_0525] 애니메이션 노티파이
[데브루키_언리얼스터디_0525] 애니메이션 노티파이MinGeun Park
 
[데브루키] 이벤트 드리븐 아키텍쳐
[데브루키] 이벤트 드리븐 아키텍쳐[데브루키] 이벤트 드리븐 아키텍쳐
[데브루키] 이벤트 드리븐 아키텍쳐MinGeun Park
 
[데브루키 언리얼 스터디] PBR
[데브루키 언리얼 스터디] PBR[데브루키 언리얼 스터디] PBR
[데브루키 언리얼 스터디] PBRMinGeun Park
 
[데브루키 언리얼 스터디] 스터디 안내 OT
[데브루키 언리얼 스터디] 스터디 안내 OT[데브루키 언리얼 스터디] 스터디 안내 OT
[데브루키 언리얼 스터디] 스터디 안내 OTMinGeun Park
 
[데브루키/페차쿠차] 유니티 프로파일링에 대해서 알아보자.
[데브루키/페차쿠차] 유니티 프로파일링에 대해서 알아보자.[데브루키/페차쿠차] 유니티 프로파일링에 대해서 알아보자.
[데브루키/페차쿠차] 유니티 프로파일링에 대해서 알아보자.MinGeun Park
 
[데브루키] Color space gamma correction
[데브루키] Color space gamma correction[데브루키] Color space gamma correction
[데브루키] Color space gamma correctionMinGeun Park
 
유니티 팁&트릭 Unity Tip & Trick
유니티 팁&트릭 Unity Tip & Trick유니티 팁&트릭 Unity Tip & Trick
유니티 팁&트릭 Unity Tip & TrickMinGeun Park
 
Live2D with Unity - 그녀들을 움직이게 하는 기술 (알콜코더 박민근)
Live2D with Unity - 그녀들을 움직이게 하는 기술 (알콜코더 박민근)Live2D with Unity - 그녀들을 움직이게 하는 기술 (알콜코더 박민근)
Live2D with Unity - 그녀들을 움직이게 하는 기술 (알콜코더 박민근)MinGeun Park
 
[RAPA/C++] 1. 수업 내용 및 진행 방법
[RAPA/C++] 1. 수업 내용 및 진행 방법[RAPA/C++] 1. 수업 내용 및 진행 방법
[RAPA/C++] 1. 수업 내용 및 진행 방법MinGeun Park
 
[Unite17] 유니티에서차세대프로그래밍을 UniRx 소개 및 활용
[Unite17] 유니티에서차세대프로그래밍을 UniRx 소개 및 활용 [Unite17] 유니티에서차세대프로그래밍을 UniRx 소개 및 활용
[Unite17] 유니티에서차세대프로그래밍을 UniRx 소개 및 활용 MinGeun Park
 
유니티의 툰셰이딩을 사용한 3D 애니메이션 표현
유니티의 툰셰이딩을 사용한 3D 애니메이션 표현유니티의 툰셰이딩을 사용한 3D 애니메이션 표현
유니티의 툰셰이딩을 사용한 3D 애니메이션 표현MinGeun Park
 
[데브루키160409 박민근] UniRx 시작하기
[데브루키160409 박민근] UniRx 시작하기[데브루키160409 박민근] UniRx 시작하기
[데브루키160409 박민근] UniRx 시작하기MinGeun Park
 
[160404] 유니티 apk 용량 줄이기
[160404] 유니티 apk 용량 줄이기[160404] 유니티 apk 용량 줄이기
[160404] 유니티 apk 용량 줄이기MinGeun Park
 
[160402_데브루키_박민근] UniRx 소개
[160402_데브루키_박민근] UniRx 소개[160402_데브루키_박민근] UniRx 소개
[160402_데브루키_박민근] UniRx 소개MinGeun Park
 

Mehr von MinGeun Park (20)

[CSStudy] 코딩인터뷰 완전 분석 #7.pdf
[CSStudy] 코딩인터뷰 완전 분석 #7.pdf[CSStudy] 코딩인터뷰 완전 분석 #7.pdf
[CSStudy] 코딩인터뷰 완전 분석 #7.pdf
 
[Cs study] 코딩인터뷰 완전 분석 #6
[Cs study] 코딩인터뷰 완전 분석 #6[Cs study] 코딩인터뷰 완전 분석 #6
[Cs study] 코딩인터뷰 완전 분석 #6
 
[Cs study] 코딩인터뷰 완전 분석 #5
[Cs study] 코딩인터뷰 완전 분석 #5[Cs study] 코딩인터뷰 완전 분석 #5
[Cs study] 코딩인터뷰 완전 분석 #5
 
[Cs study] 코딩인터뷰 완전 분석 #3
[Cs study] 코딩인터뷰 완전 분석 #3[Cs study] 코딩인터뷰 완전 분석 #3
[Cs study] 코딩인터뷰 완전 분석 #3
 
[Cs study] 코딩인터뷰 완전 분석 #2
[Cs study] 코딩인터뷰 완전 분석 #2[Cs study] 코딩인터뷰 완전 분석 #2
[Cs study] 코딩인터뷰 완전 분석 #2
 
[Cs study] 코딩인터뷰 완전 분석
[Cs study] 코딩인터뷰 완전 분석[Cs study] 코딩인터뷰 완전 분석
[Cs study] 코딩인터뷰 완전 분석
 
[데브루키_언리얼스터디_0525] 애니메이션 노티파이
[데브루키_언리얼스터디_0525] 애니메이션 노티파이[데브루키_언리얼스터디_0525] 애니메이션 노티파이
[데브루키_언리얼스터디_0525] 애니메이션 노티파이
 
[데브루키] 이벤트 드리븐 아키텍쳐
[데브루키] 이벤트 드리븐 아키텍쳐[데브루키] 이벤트 드리븐 아키텍쳐
[데브루키] 이벤트 드리븐 아키텍쳐
 
[데브루키 언리얼 스터디] PBR
[데브루키 언리얼 스터디] PBR[데브루키 언리얼 스터디] PBR
[데브루키 언리얼 스터디] PBR
 
[데브루키 언리얼 스터디] 스터디 안내 OT
[데브루키 언리얼 스터디] 스터디 안내 OT[데브루키 언리얼 스터디] 스터디 안내 OT
[데브루키 언리얼 스터디] 스터디 안내 OT
 
[데브루키/페차쿠차] 유니티 프로파일링에 대해서 알아보자.
[데브루키/페차쿠차] 유니티 프로파일링에 대해서 알아보자.[데브루키/페차쿠차] 유니티 프로파일링에 대해서 알아보자.
[데브루키/페차쿠차] 유니티 프로파일링에 대해서 알아보자.
 
[데브루키] Color space gamma correction
[데브루키] Color space gamma correction[데브루키] Color space gamma correction
[데브루키] Color space gamma correction
 
유니티 팁&트릭 Unity Tip & Trick
유니티 팁&트릭 Unity Tip & Trick유니티 팁&트릭 Unity Tip & Trick
유니티 팁&트릭 Unity Tip & Trick
 
Live2D with Unity - 그녀들을 움직이게 하는 기술 (알콜코더 박민근)
Live2D with Unity - 그녀들을 움직이게 하는 기술 (알콜코더 박민근)Live2D with Unity - 그녀들을 움직이게 하는 기술 (알콜코더 박민근)
Live2D with Unity - 그녀들을 움직이게 하는 기술 (알콜코더 박민근)
 
[RAPA/C++] 1. 수업 내용 및 진행 방법
[RAPA/C++] 1. 수업 내용 및 진행 방법[RAPA/C++] 1. 수업 내용 및 진행 방법
[RAPA/C++] 1. 수업 내용 및 진행 방법
 
[Unite17] 유니티에서차세대프로그래밍을 UniRx 소개 및 활용
[Unite17] 유니티에서차세대프로그래밍을 UniRx 소개 및 활용 [Unite17] 유니티에서차세대프로그래밍을 UniRx 소개 및 활용
[Unite17] 유니티에서차세대프로그래밍을 UniRx 소개 및 활용
 
유니티의 툰셰이딩을 사용한 3D 애니메이션 표현
유니티의 툰셰이딩을 사용한 3D 애니메이션 표현유니티의 툰셰이딩을 사용한 3D 애니메이션 표현
유니티의 툰셰이딩을 사용한 3D 애니메이션 표현
 
[데브루키160409 박민근] UniRx 시작하기
[데브루키160409 박민근] UniRx 시작하기[데브루키160409 박민근] UniRx 시작하기
[데브루키160409 박민근] UniRx 시작하기
 
[160404] 유니티 apk 용량 줄이기
[160404] 유니티 apk 용량 줄이기[160404] 유니티 apk 용량 줄이기
[160404] 유니티 apk 용량 줄이기
 
[160402_데브루키_박민근] UniRx 소개
[160402_데브루키_박민근] UniRx 소개[160402_데브루키_박민근] UniRx 소개
[160402_데브루키_박민근] UniRx 소개
 

[Pl in c++] 9. 다형성