2013-04-14 1 views
0

상황 : 그래서 분명히 컴파일러는 불평 VarRecord.hCompressor.h 모두 동일한 파일 GlobalConstants.h이 포함#INCLUDE 반복

#ifndef VAR_RECORD_SONG_H 
#define VAR_RECORD_SONG_H 

#include "VarRecord.h" 
#include "Compressor.h" 

class VarRecordSong : public VarRecord 
{ 
    public: 
     VarRecordSong(); 
     ~VarRecordSong(); 
}; 

#endif /* VAR_RECORD_SONG_H */ 

문제 : 나는 두 include 절을 가지고 하나 개의 클래스를 가지고있다.

+5

'VarRecordSong.h'에서했던 것처럼 [Include guard] (http://en.wikipedia.org/wiki/Include_guard)를'GlobalConstants.h'에 넣으시겠습니까? –

+0

@Haroogan LOL 네 말이 맞아. 고맙습니다. –

답변

2

파일 GlobalConstants.h은 다음과 같이해야합니다 :

#ifndef GLOBAL_CONSTANTS_H 
#define GLOBAL_CONSTANTS_H 

file contents... 

#endif 

그래서이 파일은 사전 처리 코드를 한 번 표시됩니다.