【发布时间】:2011-11-23 01:44:20
【问题描述】:
可能重复:
What does const mean following a function/method signature?
继续笑我,但是函数后面的const表示什么?
int someFunc() const{ //<<----notice the const
//insert code blah...
}
如果我想要一个 const int 的返回类型,我不会写
const int someFunc(){
//code....
}
【问题讨论】:
-
我会说它也是重复的。我真的不知道我在寻找什么,这是一种晦涩难懂的东西
-
顺便说一下,返回类型
int和const int100% 相同。编译器会忽略标量返回类型的顶级consts。 -
这实际上是有道理的,谢谢@FredOverflow
标签: c++