c++ multiple definitions of a variable

I’m not going to include all of the details, but you define a global variable, wat twice in your compilation uint.

To fix, use the following:

FileB.h

extern int wat;

FileB.cpp

int wat = 0;

This (extern) tells the compile that the variable wat exists somewhere, and that it needs to find it on it’s own (in this case, it’s in FileB.cpp)

Leave a Comment