
C++에서 struct는 멤버 변수들의 메모리 배치를 최적화하기 위해 패딩(padding)을 추가할 수 있다. 기본 구조체의 메모리 크기 확인기준은 구조체에서 가장 자료형이 큰것을 선정한다.여기서는 float인데 char의 경우 사실상 1 byte이기 때문에 float 4byte를 선정한다.int main(){ struct Person { float height; // 4 bytes float weight; // 4 bytes char name[10]; // 10 bytes short grade; // 2 bytes }; std::cout // height, grade, weight, name 순..