077.C++中的引用-引用的注意事项


#include 
using namespace std;
int main()
{
    int a = 10;
    //1.引用必须初始化
    //int& b;//错误,必须初始化
    int& b = a;
    //2.引用初始化后,不可以更改
    int c = 20;
    b = c;//赋值操作,而不是更改引用
    cout << "a=" << a << endl;
    cout << "b=" << b << endl;
    cout << "c=" << c << endl;
    system("pause");
    return 0;
}
C++