Skip to content

Commit b08fae0

Browse files
committed
struct and enum
Signed-off-by: ericyuanhui <ericxu890302@gmail.com>
1 parent 370a74b commit b08fae0

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include <stdio.h>
2+
#include <atomic>
3+
#include <iostream>
4+
5+
using namespace std;
6+
7+
enum objectcacher{
8+
l_objectcacher_first = 25000,
9+
10+
l_objectcacher_cache_ops_hit, // ops we satisfy completely from cache
11+
l_objectcacher_cache_ops_miss, // ops we don't satisfy completely from cache
12+
13+
l_objectcacher_cache_bytes_hit, // bytes read directly from cache
14+
15+
l_objectcacher_cache_bytes_miss, // bytes we couldn't read directly
16+
17+
// from cache
18+
19+
l_objectcacher_data_read, // total bytes read out
20+
l_objectcacher_data_written, // bytes written to cache
21+
l_objectcacher_data_flushed, // bytes flushed to WritebackHandler
22+
l_objectcacher_overwritten_in_flush, // bytes overwritten while
23+
// flushing is in progress
24+
25+
l_objectcacher_write_ops_blocked, // total write ops we delayed due
26+
// to dirty limits
27+
l_objectcacher_write_bytes_blocked, // total number of write bytes
28+
// we delayed due to dirty
29+
// limits
30+
l_objectcacher_write_time_blocked, // total time in seconds spent
31+
// blocking a write due to dirty
32+
// limits
33+
34+
l_objectcacher_last,
35+
};
36+
37+
struct{
38+
char *name; //姓名
39+
int num; //学号
40+
int age; //年龄
41+
char group; //所在小组
42+
float score; //成绩
43+
} stu1;
44+
45+
int main()
46+
{
47+
atomic<int> ato_num(0);
48+
cout << "ato num " << ato_num << endl;
49+
atomic_int ato_int(10);
50+
cout << "ato int " << ato_int << endl;
51+
enum objectcacher test = l_objectcacher_data_read;
52+
printf("test enum %d \n", test);
53+
//给结构体成员赋值
54+
55+
stu1.name = "Tom";
56+
stu1.num = 12;
57+
stu1.age = 18;
58+
stu1.group = 'A';
59+
stu1.score = 136.5;
60+
61+
printf("%s的学号是%d,年龄是%d,在%c组,今年的成绩是%.1f!\n", stu1.name, stu1.num, stu1.age, stu1.group, stu1.score);
62+
return 0;
63+
}

0 commit comments

Comments
 (0)