4 つのファイル (2 つのヘッダーと 2 つのコード ファイル) があります。FileA.cpp、FileA.h、FileB.cpp、FileB.h
FileA.cpp:
#include "FileA.h"
int main()
{
hello();
return 0;
}
void hello()
{
//code here
}
ファイルA.h:
#ifndef FILEA_H_
#define FILEA_H_
#include "FileB.h"
void hello();
#endif /* FILEA_H_ */
FileB.cpp:
#include "FileB.h"
void world()
{
//more code;
}
FileB.h:
#ifndef FILEB_H_
#define FILEB_H_
int wat;
void world();
#endif /* FILEB_H_ */
(Eclipse で) コンパイルしようとすると、「'wat' の複数の定義」が表示されます。理由はわかりませんが、問題なく動作するはずです。