解析:C++的重載的兩個(gè)函數(shù)參數(shù)數(shù)量可以相同也可以不同,當(dāng)參數(shù)數(shù)量相同時(shí),只需要對(duì)應(yīng)參數(shù)類型不同即稱為重載
2019-09-03
&和*的理解是對(duì)指針使用的關(guān)鍵,int *x 和 int &x 、 &x 、*x其實(shí)都是不一樣的
2019-05-11
//正常的引用操作
#include <iostream>
using namespace std;
int main(void)
{
int x = 3;
//定義引用,y是x的引用
int &y = x;
//打印x和y的值
cout << x << endl;
cout << y << endl;
//修改y的值
y = 10;
//再次打印x和y的值
cout << x << endl;
cout << y << endl;
return 0;
}
#include <iostream>
using namespace std;
int main(void)
{
int x = 3;
//定義引用,y是x的引用
int &y = x;
//打印x和y的值
cout << x << endl;
cout << y << endl;
//修改y的值
y = 10;
//再次打印x和y的值
cout << x << endl;
cout << y << endl;
return 0;
}