【发布时间】:2022-01-08 09:29:02
【问题描述】:
中的参数有什么区别:
int foo1(const Fred &arg) {
...
}
和
int foo2(Fred const &arg) {
...
}
? 我在 parashift 常见问题解答中没有看到这种情况。
【问题讨论】:
-
这是关于风格的问题吗? “const Fred”在英语中听起来不错,但“Fred const”在我看来更好。
-
在相关说明中,有什么理由应该更喜欢
Fred const &arg而不是Fred const& arg?我更喜欢后者,因为const&是一个单位,意思是“constref”,名称arg与所有类型说明符用空格隔开。 -
@dehmann:但
int const& ref并不是指“const ref”而是“ref to const”。