문제

Context: I've got one class which has two include clauses:

#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 */ 

Problem: both VarRecord.h and Compressor.h include the same file GlobalConstants.h, so obviously the compiler complains.

도움이 되었습니까?

해결책

The file GlobalConstants.h should be like this:

#ifndef GLOBAL_CONSTANTS_H
#define GLOBAL_CONSTANTS_H

file contents...

#endif

So this file will only appear once in the pre-processed codes.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top