int const a=3;
int *p=&a;
存在通過*p改變常量a值的風(fēng)險(xiǎn),故修改為:const int *p=&a;
int *p=&a;
存在通過*p改變常量a值的風(fēng)險(xiǎn),故修改為:const int *p=&a;
2015-11-17
內(nèi)聯(lián)函數(shù),沒有犧牲內(nèi)存空間而去提高運(yùn)行速度!應(yīng)該是類似移動(dòng)插入,當(dāng)執(zhí)行到調(diào)用函數(shù)時(shí)候,該函數(shù)是內(nèi)聯(lián)函數(shù),這時(shí)候就把該函數(shù)的函數(shù)代碼直接插入到該調(diào)用代碼位置!
2015-10-30
# include <iosstream>
useing namespace std;
ina main ()
{
int x = 3;
int &y = x;
count << x << ","<<y<<endl;
y = 13;
count << x << "," << y << endl;
return 0;
}
useing namespace std;
ina main ()
{
int x = 3;
int &y = x;
count << x << ","<<y<<endl;
y = 13;
count << x << "," << y << endl;
return 0;
}
#include <iostream>
using namespace std;
int main(void)
{
int x = 3;
//定義引用,y是x的引用
int &y=x;
//打印x和y的值
cout << x <<"," <<y <<endl;
//修改y的值
y = 10;
//再次打印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 = 10;
//再次打印x和y的值
cout << x<<","<<y <<endl;
return 0;
}