引用

#include <iostream>
#include <cstring>
#define print(x)  std::cout << x << std::endl;
void change(int &a,int &b){
    int temp = a;
    a = b;
    b = temp;
}
int main(void) {
    int a = 10;
    int b = 20;
    change(a,b);
    print(a);
    print(b);
}

指针

#include <iostream>
#define print(x) std::cout << x << std::endl
#define input(x) std::cin >> x
void change(int *a,int *b){
    int temp = *a;
    *a = *b;
    *b = temp;
}
int main()
{
    int a = 10;
    int b = 20;
    change(&a,&b);
    print(a);
    print(b);
}