代码:
#include "head.h"
#include <iostream>
static int b = 10;
int main()
{
extern int a;
a = 20;
b = 20;
std::cout << "a=" << a << std::endl;
std::cout << "b=" << b << std::endl;
}
不是说在一个文件中定义了一个static变量则不能在其他文件中引用。
代码:
#include "head.h"
#include <iostream>
static int b = 10;
int main()
{
extern int a;
a = 20;
b = 20;
std::cout << "a=" << a << std::endl;
std::cout << "b=" << b << std::endl;
}
不是说在一个文件中定义了一个static变量则不能在其他文件中引用。