일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- c++ basic practice
- virtual inheritance
- discord bot
- delete function
- std::endl
- vector size
- constructor
- std::cout
- return by reference
- base from member
- virtual function table
- vector capacity
- suffix return type
- 더 지니어스 양면포커
- new&delete
- C++
- this call
- increment operator
- c++ multi chatting room
- std::vector
- dynamic_cast
- pointer to member data
- diamond inheritance
- virtual destructor
- std::ostream
- member function pointer
- placement new
- conversion constructor
- operator overloading
- virtual function
- Today
- Total
목록virtual function (2)
I'm FanJae.

※ 본 포스트는 코드누리 C++ Basic 강의 내용을 보고 정리한 포스트입니다. 1. 가상 함수에 대한 의문점class Base{ int bm{0};public: virtual void f1() {} virtual void f2() {} virtual void f3() {}};class Derived : public Base{ int dm{0};public: void f2() override {}};int main(){ Base base; Dervied derived; Base *p = &derived; p->f2();}- 지난 시간 가상 함수에 대해 다뤘다.- 이때, p->f2(); 에서 어느 함수를 호출 할 것인가에 대한 이야기이다. - ..

※ 본 포스트는 코드누리 C++ Basic 강의 내용을 보고 정리한 포스트입니다. 1. UpCasting#include class Animal{ std::string name; int age;public: void cry() { }};class Dog : public Animal{ int color;public: void setColor(int c) { color = c; }};int main(){ Dog dog; Dog* p1 = &dog; // ok // int* p2 = &dog; // Error Animal* p3 = &dog;}- UpCasting이란, 기반 클래스 포인터로 파생 클래스 객체를 가리키는 행위를 의미한다.- 메모리 레이아웃 차원에서 보면, 파생 클래스(Derived Class)인..