How are local and global variables initialized by default?

后端 未结 10 1677
粉色の甜心
粉色の甜心 2020-11-30 10:39

Based on below, am i right?

  • global_A reference is initialized to null.
  • global_int is 0
  • local_A reference is null
  • local_int is uninit
10条回答
  •  南方客
    南方客 (楼主)
    2020-11-30 10:55

    global_A and local_A are not references; they are objects and created using their default constructors. Default constructor has not been specified so it will be generated, which will do nothing so the member variable will remain uninitialized.

提交回复
热议问题