Local/static variable scope in C++
#include <iostream>
int main()
{
using namespace std;
{int n;n=5;} cout<<n;
system("pause");
return 0;
}
本文通过一个简单的C++示例程序展示了局部静态变量的作用范围,并解释了当尝试在作用域外部访问局部静态变量时发生的编译错误。通过这个例子,读者可以更好地理解C++中局部静态变量的行为。
#include <iostream>
int main()
{
using namespace std;
{int n;n=5;} cout<<n;
system("pause");
return 0;
}
1048

被折叠的 条评论
为什么被折叠?