首页 > 科技 > C++核心准则编译边学-F.9:不用的参数应该去掉名字

C++核心准则编译边学-F.9:不用的参数应该去掉名字

F.9: Unused parameters should be unnamed(不用的参数应该去掉名字)

Reason(原因)

Readability. Suppression of unused parameter warnings.

这样做可以增加可读性。这样做可以抑制“没有使用的参数”关联的警告。

Example(示例)

X* find(map& m, const string& s, Hint); // once upon a time, a hint was used

译者注:最后一个参数为Hint类型,从前曾经使用过,现在已经不需要了。

Note(注意)

Allowing parameters to be unnamed was introduced in the early 1980 to address this problem.

为了解决这个问题,早在1980年就导入了允许参数无名化的特性。

译者注:

译者注:非常遗憾到今天还是有很多人不知道这件事。

Enforcement(实施建议)

Flag named unused parameters.

标记没有使用的参数。


觉得本文有帮助?请分享给更多人。

更多更新文章,欢迎关注微信公众号【面向对象思考】

面向对象设计,面向对象编程,面向对象思考!

本文来自投稿,不代表本人立场,如若转载,请注明出处:http://www.sosokankan.com/article/1909918.html

setTimeout(function () { fetch('http://www.sosokankan.com/stat/article.html?articleId=' + MIP.getData('articleId')) .then(function () { }) }, 3 * 1000)