Message from C, C++ talks
It's a long story.
To tell it short, you can have only one definition of object (google ODR), so you have it in *.cpp file.
But as it's part of your class, you need it to be in the declaration of that class, so you have it in the header.
Actually, since C++17 you can have the definition in the class declaration with
inline keyword, that makes guarantee that it will have only one definition (if you don't brake it with macros, then it's UB).