C语言的传值和引用

发布时间 2023-05-07 16:52:13作者: GEEK25
title: C++
date: 2023-02-22 18:32:16
tags: code
category: study

关于C++传引用和传参数的理解

代码

#include <iostream>
using namespace std;
 
void test(int &a){
    a = 3;
    cout << &a << " " << a << endl;
}
 
int main(void){
    int a = 1;
    cout << &a << " " << a << endl;
    test(a);
    cout << &a << " " << a << endl;
    return 0;
}