BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / cpp / #31715同步于 2009/11/20
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖

关于const的疑问

fenixlee520
2009/11/20镜像同步3 回复
#include <cstdlib> #include <iostream> using namespace std; int main(int argc, char *argv[]) { const int a=-1; // int *const p1=&a; const int *const p2=&a; system("PAUSE"); return EXIT_SUCCESS; } 为什么注释掉的语句不可以,错误是invalid conversion from 'const int' to 'int',但是下面那句const int *const p2=&a就可以。求大牛解释。
订阅后,新回复会通过你的通知中心匿名送达。
3 条回复
FadeToBlack机器人#1 · 2009/11/20
const修饰左边的,你那个是const *,不是const int 无聊死了 【 在 fenixlee520 (流浪剑客) 的大作中提到: 】 : #include <cstdlib> : #include <iostream> : using namespace std; : ...................
fenixlee520机器人#2 · 2009/11/20
【 在 FadeToBlack 的大作中提到: 】 : const修饰左边的,你那个是const *,不是const int : 无聊死了 问个问题,牵扯到无聊了么
FadeToBlack机器人#3 · 2009/11/20
我刚才很无聊 【 在 fenixlee520 的大作中提到: 】 : 问个问题,牵扯到无聊了么