c ++ mehrere Definitionen einer Variablen
Ich habe 4 Dateien (2 Header und 2 Code-Dateien). FileA.cpp, FileA.h, FileB.cpp, FileB.h
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_ */
Wenn ich versuche zu kompilieren (mit Eclipse), erhalte ich eine "Mehrfachdefinition von" wat ". Und ich weiß nicht warum, es scheint, als ob es gut funktionieren sollte.