Quote: "in both your main.cpp and in lol.cpp. This essentially says you're code in lol.h is duplicated in both places. You need to get in the habit of insuring that this doesn't happen with your header files."
This isn't the problem. Header guards will make sure a header isn't included multiple times in the same object file (source file), but it can be included at least once in each source file. The problem is that the variable is being defined in multiple source files, which is not allowed.
Variables should
never be defined in header files, only in source files. You may
declare variables in header files using the
extern keyword, which basically means "this variable is defined in another file".
What you need to do is put this in the header file:
extern int digit; // You're not allowed to assign a value here
And put this in a relevant source file:
int digit = 0; // Definition, you are allowed to assign a value here
Quote: "You can't initialize variables unless they are in a function."
You can initialize them in the global scope too.