So, prior to C++11, in-class member initialization of non-const and non-static variables was not allowed.
Bjarne Stroustrup’s reasoning was that the one-definition rule “would be broken if C++ allowed in-class definition of entities that needed to be stored in memory as objects.“
What did he mean by this?
I do understand that the one-definition rule mandates that only one definition of an entity that exists in memory should be allowed per program. But I still cannot see why the rule would be broken.
My question is related to this question, but I’m asking a different question, specifically for clarification on how the one-definition rule would have gotten broken.
I watched a Back to Basics talk by Bob Steagall – “The Structure of a Program”. And looked at some other related questions. But I still cannot understand Stroustrup’s assertion.
centauri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.