返回信息流#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就可以。求大牛解释。
这是一条镜像帖。来源:北邮人论坛 / cpp / #31715同步于 2009/11/20
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
关于const的疑问
fenixlee520
2009/11/20镜像同步3 回复
订阅后,新回复会通过你的通知中心匿名送达。
3 条回复
const修饰左边的,你那个是const *,不是const int
无聊死了
【 在 fenixlee520 (流浪剑客) 的大作中提到: 】
: #include <cstdlib>
: #include <iostream>
: using namespace std;
: ...................
【 在 FadeToBlack 的大作中提到: 】
: const修饰左边的,你那个是const *,不是const int
: 无聊死了
问个问题,牵扯到无聊了么