-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitialize.cpp
More file actions
36 lines (27 loc) · 842 Bytes
/
Copy pathinitialize.cpp
File metadata and controls
36 lines (27 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// Created by 陈希明 on 18/1/26.
// 编译器:c++
//
#include <iostream>
using namespace std;
struct test{
public:
string s;
int i;
};
int global_i; //全局内置类型初始化为0
test global_t;
int main()
{
int local_i; //局部内置类型不默认初始化,值未定义
static int static_i; //静态内置类型值初始化,为0
test local_t;
static test static_t;
cout << "global int:" << global_i << endl; //0
cout << "local int:" << local_i << endl; //未定义
cout << "static int:" << static_i << endl; //0
cout << "global test:" << global_t.s << "," << global_t.i << endl; // "",0
cout << "local test:" << local_t.s << "," << local_t.i << endl; // "",未定义
cout << "static test:" << static_t.s << "," << static_t.i << endl; // "",0
return EXIT_SUCCESS;
};