const and static variables, which can be placed in the header file
const objects are static by default, not extern, so they are declared and defined in the header file. Multiple CPP references the same header file and is not aware of each other, so it does not cause duplicate definitions.
class definition, which can be placed in a header file
When you create an object with a class, the compiler knows how the object is laid out to allocate memory, so the definition of the class needs to be in the header file. In general, we put the definition of the member function within the class in the CPP file, but if the function declaration + definition is done directly in class, this function will be treated as inline by the compiler, thus satisfying the rule that the above inline function can be placed in the header file. But if the declaration and definition are implemented separately, but all are placed in the header file, then the duplicate definition will be reported!!
https://zybuluo.com/uuprince/note/81709
The const object is static by default, not extern