C++引用相关练习
我要参与
C++引用相关练习
学习任务 2.1k
等11人参与
来源: 第17周 / 物联网/嵌入式工程师

任务

  1. 设计一个函数my_swap,实现两个数的交换,请分别使用指针和引用进行实现
  2. 请修复下面程序中的错误
#include <iostream>

using namespace std;

void change(const int &a)
{
    a ++;
}

void printf_string(string str)
{        
    cout << "str:" << str << endl;
}

int main(void)
{        
    int a = 10;   
         
    change(a);        
    cout << "a = " << a << endl;                
    string str = "hello";       
    printf_string(str);        
    printf_string("world");
    
    return 0;
}
去发布

登录后即可发布作业,立即

我的作业

全部作业

微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师