【发布时间】:2012-06-19 19:07:32
【问题描述】:
我有 4 个文件(2 个标头和 2 个代码文件)。 FileA.cpp、FileA.h、FileB.cpp、FileB.h
文件A.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_ */
文件B.cpp:
#include "FileB.h"
void world()
{
//more code;
}
文件B.h:
#ifndef FILEB_H_
#define FILEB_H_
int wat;
void world();
#endif /* FILEB_H_ */
当我尝试编译(使用 eclipse)时,我得到“'wat' 的多重定义” 而且我不知道为什么,它似乎应该可以正常工作。
【问题讨论】:
标签: c++ compiler-errors