Static data members must be explicitly defined exclusively in one source file. Here’s an example of a header file, such as MyClass.h:
class MyClass { public: static int x; // Declare (not define) static member MyClass::x };
The linker will generate an error (