-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpp-variable-types.cpp
More file actions
69 lines (58 loc) · 1.38 KB
/
cpp-variable-types.cpp
File metadata and controls
69 lines (58 loc) · 1.38 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
// Created by zhang on 2017/9/11.
//
#include <iostream>
using namespace std;
// 变量声明
extern int a, b;
extern int c;
extern float f;
int main() {
// 变量定义
int a, b;
int c;
float f;
// 实际初始化
a = 10;
b = 20;
c = a + b;
cout << c << endl;
f = 70.0 / 3.0;
cout << f << endl;
cout << "Size of char : " << sizeof(char) << endl;
cout << "Size of int : " << sizeof(int) << endl;
cout << "Size of short int : " << sizeof(short int) << endl;
cout << "Size of long int : " << sizeof(long int) << endl;
cout << "Size of float : " << sizeof(float) << endl;
cout << "Size of double : " << sizeof(double) << endl;
cout << "Size of wchar_t : " << sizeof(wchar_t) << endl;
/**
* enum 枚举名{
* 标识符[=整型常数],
* 标识符[=整型常数],
* ...
* 标识符[=整型常数]
* } 枚举变量
*/
enum days {
one = 1, two = 2, three = 3
} day;
day = one;
days days1;
days1 = two;
cout << "days1 is " << days1 << endl;
switch (day) {
case one:
cout << "one" << endl;
break;
case two:
cout << "two" << endl;
break;
default:
cout << "three" << endl;
break;
}
typedef int INT;
cout << "INT sizeof is " << sizeof(INT);
return 0;
}