How do I declare a global variable in C++ ? I thought I declared the variable as static in the .cpp file and then declared the definition of that variable in the .h file. But I get a C2086 - redefinition.
// the Train2a.cpp file #include "stdafx.h" #include "Train2a.h" namespace steve { int GlobalCounter = 25 ; }
// the Train2a.h file #pragma once #include "stdafx.h" namespace steve { static int GlobalCounter ; }