#include <iostream> #include <Windows.h> using namespace std; void Change1(int*& a, int*& b) { int* tmp = a; a = b; b = tmp; } int main() { int a = 6, b = 221; int *p = &a, *q = &b; cout << "交换前:" << endl; cout << "p=" << p << ",q=" << q << endl; cout << "p所指的值:" << *p << ",q所指的指:" << *q << endl; Change1(p, q); cout << "交换后:" << endl; cout << "p=" << p << ",q=" << q << endl; cout << "p所指的值:" << *p << ",q所指的指:" << *q << endl; }标签:tmp,int,令其,编写,include,指针 From: https://www.cnblogs.com/smartlearn/p/17558228.html