返回指针向量?
可能的重复:
const int*、const int * const 和 int const * 之间有什么区别?
const int = int const?
以下三个有什么区别?
vector<int const *> f() { ... }
vector<const int *> g() { ... }
vector<int * const> h() { ... }
Possible Duplicate:
What is the difference between const int*, const int * const, and int const *?
const int = int const?
What's the difference between the following three?
vector<int const *> f() { ... }
vector<const int *> g() { ... }
vector<int * const> h() { ... }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
什么都没有(除了函数的名称)。
在这两种情况下,const 都会修改 int,而不是指针。
Nothing (except the name of the function).
In both cases,
const
modifies theint
, not the pointer.没有什么区别;
int const
和const int
含义相同。通常,
const
引用其左侧的类型:int const *
是指向常量整数的指针,而不是指向常量整数的常量指针(非常量)整数。将const
放在最开头是一种特殊情况,它引用其右侧的类型。There's no difference;
int const
andconst int
mean the same thing.Ordinarily,
const
refers to the type on its left: aint const *
is a pointer to a constant integer, not a constant pointer to a (non-constant) integer. Puttingconst
at the very beginning is a special case, where it refers to the type on its right.一个叫f,另一个叫g。就是这样。
const 应用于左侧的元素。如果左侧没有元素,则应用于右侧元素。
One's named f, the other is named g. That's it.
const is applied to the element to the left. In the case where there is no element to the left, it is applied to the element to the right.