C++ forums 的Const char *p ,当是学习英语
个人翻译,水平太poor,多多指教Which one is constant?
那个是常量
p
or *p?
And how do we tell?
告诉我们怎样做
This confuses me all the way till now
搞到我很混乱
Zhuge (1098) Jan 4, 2011 at 10:54am
When you have a pointer to some type T, the constness is as follows:
当你有一个指针对类型T,常量如下
1
2
3
const T* ptr; // pointer to a constant T 指针指向常量T
T const* ptr; // pointer to a constant T 指针指向常量T
T* const ptr; // constant pointer to a T 常量指针指T