zoukankan      html  css  js  c++  java
  • c++引用

    • 引用的本质---一个常量指针
    #include<iostream>
    using namespace std;
    void crzaychange(int &a, int &b)
    {
        int c;
        c = a;
        a = b;
        b = c;
    }
    
    void main()
    {
        int a = 100;
        int b = 88;
        crzaychange(a,b);
        cout << "now a is:" <<a<< endl;
        system("pause");
    }
    • 交换字符串指针指向的值
    #include<iostream>
    using namespace std;
    
    
    void swapelements(char *&a,char *&b)
    {
        char* c;
        c = a;
        a = b;
        b = c;
    }
    
    void main()
    {
        char a[100] = "727 is ready to move ";
        char b[100] = "it's a long ong jurney to the other side";
        char *pa = a;
        char *pb = b;
        cout << "now a is:" << pa << endl;
    
        swapelements(pa, pb);
        cout << "now a is:" << pa << endl;
    
        system("pause");
    }
    #include<iostream>
    using namespace std;
    
    void swapelements(char *&a,char *&b)
    {
        char* c;
        c = a;
        a = b;
        b = c;
    }
    
    void main()
    {
        char *a= "727 is ready to move ";
        char *b = "it's a long ong jurney to the other side";
        
        cout << "now a is:" << a << endl;
    
        swapelements(a, b);
        cout << "now a is:" << a << endl;
    
        system("pause");
    }

    输出结果:

  • 相关阅读:
    大数乘法
    大数阶乘
    存js导入excel文件
    设计模式详解
    javascript的api设计原则
    从零开始nodejs系列文章
    git的学习
    如何暴力学英语
    Vsftpd
    shell命令学习
  • 原文地址:https://www.cnblogs.com/saintdingspage/p/12057702.html
Copyright © 2011-2022 走看看