首页 > 代码库 > An error from other projects which impress me most
An error from other projects which impress me most
I cannot remember what the specific c++ project is, but what impressed me most is the definition of constant pointer.
If we want to define a pointer which the address content is able to change, we can‘t use char const * p, for example:
- char const *p;
- p=str;
- *p=‘n‘;
we will get an error message:
错误: 向只读位置‘*p’赋值
char * const p; //define a pointer which the address is unable to change
char const * p;//define a pointer which the address content is unable to change
const char *p; //the same as char const *p
An error from other projects which impress me most
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。