指针与运用(Pointers):
Mar 10, 2025 · 4 min read · 引用运算符(&):
基本引用
#include <iostream>
int main() {
int a = 10;
int& ref = a; // ref 是 a 的引用,ref 和 a 绑定在一起
ref = 20; // 修改 ref 也会修改 a
std::cout << "a: " << a << std::endl; // 输出 20
return 0;
}
函数参数中的作用
传递变量的引用:
#inc...