美文网首页
1.引用的基本语法

1.引用的基本语法

作者: lxr_ | 来源:发表于2021-01-13 11:10 被阅读0次
    #include<iostream>
    using namespace std;
    
    //引用:给变量起别名(可操作同一块内存空间)
    //语法:数据类型& 别名=原名
    
    int main()
    {
        int a = 10;
        //创建引用
        int& b = a;
        cout << "a=" << a << endl;
        cout << "b=" << b << endl;
        b = 20;
        cout << "a=" << a << endl;
        cout << "b=" << b << endl;
    
    
        system("pause");
        return 0;
    }
    

    相关文章

      网友评论

          本文标题:1.引用的基本语法

          本文链接:https://www.haomeiwen.com/subject/icruaktx.html