C ++ forces the programmer to define a non-constant static member outside the class, and the reason I continue to see is that if the static member was defined inside the class, this will lead to several definitions for the static member. I understand that a few definitions for a static member are bad, but I do not understand where these multiple definitions may arise. There should not be an initialized non-constant static member, just go to the data section and this will be the only definition?
struct Student { static int x = 4;
In addition, I read in this other stackoverflow post that const const members are simply inserted into the code wherever it is used: Why don't I have a non-stationary static const member in the class? Is this handled by the preprocessor along with all the other directives? (I will ask about this in another post, if necessary, but I was not sure if he was worthy of a separate post).
source share