C.49's good example is the same what was defined as a bad example in C.45. Your good examples should not contradict your own rules
Agreed. We could just put /* ... */ in the default constructor in the C.49 example, suggesting it does something _other_ than simply initialize the member. Or we could add a "better" example that follows C.45, with a cross-reference.
Would
class X {
string s;
public:
X(string n) :s{n} { } // GOOD
// ...
};
Be a better 'good' example? as opposed to
X(string n) { s = n; } // BAD
Yes, that works too. The B example should be changed similarly.
Thank you for the suggestions! We agree, especially with the sample provided by @xtofl. @rmasp98, could you please prepare a PR?
Done! (https://github.com/isocpp/CppCoreGuidelines/pull/1092)
The PR #1092 was merged and closed, so shouldn't this issue be closed, too?
Most helpful comment
Would
Be a better 'good' example? as opposed to