#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 定義的是常量指針??梢岳斫鉃閜是指向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