I have some extern‘d variables in a namespace in a header file, and I’m trying to initialize them in its corresponding cpp file. However, I keep getting the error given in the topic title. I’m not sure what the problem is.
EX:
// Some header
namespace foo
{
extern SDL_Surface* bar;
}
// In the impl file
#include "someheader.h"
foo::bar = 0;
.....
Any assistance is appreciated. Thanks.
At the file level, you can only define types (you’ve only written an assignment expression). So you need to change that to: