once (1) 썸네일형 리스트형 #pragma once test1.h struct Test1 { int a; int b; }; test2.h #include "test1.h" struct Test2 { Test1 a; }; test3.h #include "test1.h" struct Test3 { Test1 a; char b; }; test.cpp #include "test2.h" #include "test3.h" 이때, test2.h와 test3.h는 공통적으로 test1.h를 포함하고 있는데 test.cpp에서 test2.h와 test3.h를 포함하는 바람에 test1.h이 2개 포함돼 버려 헤더 중복이 됩니다. 즉, Test1가 두 번 정의되어 오류가 납니다. 문제를 해결하기 위해서 test1.h 코드를 다음과 같이 바꿉니다. #ifndef TEST1_.. 이전 1 다음