day - 5 基础知识总结&问题解决

2021/9/25 23:14:55

本文主要是介绍day - 5 基础知识总结&问题解决,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

static分文件操作
//文件1
int x = 10;
static int y = 100;
//文件2
#include <iostream>
using namespace std;

extern int x;
extern int y;

int main() {
    cout << x << y ;

    return 0;
}
//undefined reference to `y',系统报错,可以知道static修饰变量y作用域仅在t2.cpp中,而不使用static则在另外一个文件中可以使用,如上面的变量x


这篇关于day - 5 基础知识总结&问题解决的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程