C.49: Prefer initialization to assignment in constructors
 C.49:构造函数中应该做的是初始化而不是赋值
Reason(原因)
An initialization explicitly states that initialization, rather than assignment, is done and can be more elegant and efficient. Prevents "use before set" errors.
初始化明确地表明所做的是初始化而不是赋值,而且可以做得更优美,更有效率。防止“赋值之前使用”的错误。
Example, good(良好示例)
Example, bad(反面示例)
Example, better still(更好的示例)
Instead of those const char*s we could use gsl::string_span or (in C++17) std::string_view as a more general way to present arguments to a function:
相对于那些const char* s,我们应该可以使用gsl::string_span或者(C++17引入的)std::string_view作为表达函数参数怒的更加普遍的方式(https:///isocpp/CppCoreGuidelines/blob/master/#Rstr-view)。
阅读更多更新文章,请关注微信公众号【面向对象思考】
 
 
                     
            
        













 
                    

 
                 
                    