-
c++ 클래스 상속 관계에서의 메모리 정렬프로그래밍/c++ 2018. 9. 16. 20:27반응형
https://stackoverflow.com/questions/2006504/c-data-alignment-member-order-inheritance
0. 상속 관계일 때 베이스 클래스의 멤버 변수의 메모리 위치
class base { int i; }; class derived : public base // same for private inheritance { int k; };
일 때
int i; // base
int k; // derived 순서로 정렬 됨
1. 거의 모든 컴파일러는 클래스의 나머지 멤버 앞에 가상 테이블 포인터를 배치합니다. 즉, vftable 포인터와 클래스 멤버 사이에 약간의 패딩이있을 수 있습니다.
반응형'프로그래밍 > c++' 카테고리의 다른 글
static thread_local 인스턴스의 소멸 시점 (0) 2019.03.05 ::operator new, ::operator delete (0) 2018.10.03 비쥬얼 스튜디오 c++, 포인터에서 배열 보기 (0) 2018.09.09 c++17 if statement with initializer (0) 2018.08.22 Visual Studio 2017에서 google test를 사용하기 (0) 2018.08.20