程序中有未初始化静态存储变量(Variables with static storage)如全局变量,

还有局部变量,编译器为他们分配默认值时,

全局变量默认是0(zero),局部变量会随机的分配一个值,这个值并不确定,很可能编译器会报错。例如:

 

 

 

#include <iostream>
#include <string>
using namespace std;

 


int main

{

int y;
cout<<x<<'\n';
cout<<y<<'\n';

}

不报错时
0
4285838

 

相关文章:

  • 2022-12-23
  • 2021-09-25
  • 2021-06-14
  • 2022-12-23
  • 2021-11-17
  • 2021-11-17
  • 2021-12-26
猜你喜欢
  • 2021-06-09
  • 2018-09-07
  • 2021-06-20
  • 2022-12-23
  • 2021-10-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案