#include <iostream>
using namespace std;
int main(void)
{
int x = 3;
//定义引用,y是x的引用
int &y=x;
//打印x和y的值
cout << x <<","<< y <<endl;
//修改y的值
y = 222;
//再次打印x和y的值
cout << x << "," << y << endl;
return 0;
}
using namespace std;
int main(void)
{
int x = 3;
//定义引用,y是x的引用
int &y=x;
//打印x和y的值
cout << x <<","<< y <<endl;
//修改y的值
y = 222;
//再次打印x和y的值
cout << x << "," << y << endl;
return 0;
}
已采纳回答 / If丶凌
const int*p定义的是指向常量的指针;int * count p 定义的是常量指针。可以理解为p是指向count地址的指针,而*p=count,因为count是一个常量,所以是*p为一个常量,故const在int*p前面修饰整个
2016-03-21
最赞回答 / 诗情美如画
你要知道常量指针和指针常量的关系 比如: const int * p 这是常量指针 const 只是为了 将*p给绑住不让别人改它而 指针常量: int *const p是为了将p给绑住 不让别人把地址改了保证地址的安全性 const int *const p 则完全被绑住了不能修改
2016-03-20
泼点冷水: new失败后的处理不符合C++标准,为无用代码! 欲知详情,请自行搜索“C++ new 失败”。 建议对此说明...
2016-03-18