일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
- delete function
- increment operator
- return by reference
- std::cout
- dynamic_cast
- constructor
- discord bot
- 더 지니어스 양면포커
- placement new
- virtual inheritance
- vector size
- virtual destructor
- operator overloading
- C++
- new&delete
- conversion constructor
- vector capacity
- virtual function table
- std::vector
- member function pointer
- std::endl
- suffix return type
- std::ostream
- diamond inheritance
- c++ multi chatting room
- virtual function
- pointer to member data
- this call
- c++ basic practice
- base from member
- Today
- Total
목록constructor (2)
I'm FanJae.

1. 생성자(Constructor)의 생성 원리1-1. 생성자, 소멸자 호출의 정확한 원리#include struct BM // BaseMember{ BM() { std::cout - 위와 같은 코드가 존재한다고 가정하자. 그러면 실제로는 아래와 같이 변환해준다.struct Base{ BM bm; Base() : bm() { } Base(int a) : bm() {} ~Base() {...; bm.~BM(); }};struct Derived : public Base{ DM dm; Derived() : Base(), dm() { } Derived(int a) : Base(), dm() { } ~Derived..
※ 본 포스트는 코드누리 C++ Basic 강의 내용을 보고 정리한 포스트입니다. 1. 생성자가 필요한 이유#include #include class Person{public: std::string name; int age;};int main(){ Person p = {"kim",25};}- struct와 class는 사용 방법이 유사하여, 위와 같이 사용은 가능하다.- 하지만 지난 시간 OOP 포스트에서 다뤘듯, 멤버 데이터를 외부에서 접근 시키는 행위는 다소 위험하다. ① 단계 1. 멤버 데이터를 private으로 수정한다.class Peson{private: std::string name; int age;};- 따라서, 보통 멤버 데이터는 private으로 설정한다. 문제는 이..