同学问我这样的问题,例如在下面的代码中:
#include <iostream>
using namespace std;
int main() {
int a = 1;
{
int a = 2;
cout << a << endl;
}
return 0;
}
如何在内部访问到main
函数的a
?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
你可以这样做:
好吧,我承认我是故意来搞笑的,请清踩~
没有办法,里外总有一个你得换个名字。
只能做引用了: