指针与运用(Pointers):
引用运算符(&):
基本引用
#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...
cpp-blog.hashnode.dev4 min read