我有4个文件(2个头文件和2个代码文件)。 FileA.cpp,FileA.h,FileB.cpp,FileB.hC++变量的多重定义
FileA.cpp:
#include "FileA.h"
int main()
{
hello();
return 0;
}
void hello()
{
//code here
}
FileA.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'的多重定义” 我不知道为什么,它似乎应该工作得很好。
欢迎连接的世界.. –