forked from chronolaw/cpp_study
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoop.cpp
More file actions
118 lines (92 loc) · 1.83 KB
/
oop.cpp
File metadata and controls
118 lines (92 loc) · 1.83 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Copyright (c) 2050 by Chrono
//
// g++ test05.cpp -std=c++11 -o a.out;./a.out
// g++ test05.cpp -std=c++14 -o a.out;./a.out
//
#include <iostream>
#include <string>
#include <vector>
#include <set>
#if 1
class Interface {};
class Implement final : public Interface
{
public:
using super_type = Interface;
using this_type = Implement;
private:
};
#endif
#if 1
struct KafkaConfig final
{
int id;
std::string ip_addr;
};
class DemoClass final
{
public:
using this_type = DemoClass;
using kafka_conf_type = KafkaConfig;
public:
using string_type = std::string;
using uint32_type = uint32_t;
using set_type = std::set<int>;
using vector_type = std::vector<std::string>;
public:
DemoClass() = default;
~DemoClass() = default;
DemoClass(const DemoClass&) = delete;
DemoClass& operator=(const DemoClass&) = delete;
public:
explicit DemoClass(const string_type& str)
{
m_name = str;
}
explicit operator bool ()
{
return !m_name.empty();
}
public:
void set_name(const string_type& str);
private:
string_type m_name = "tom";
uint32_type m_age = 23;
set_type m_books;
private:
kafka_conf_type m_conf;
};
#endif
#if 1
class DemoDelegating final
{
private:
int a;
public:
DemoDelegating(int x) : a(x)
{}
DemoDelegating() : DemoDelegating(0)
{}
DemoDelegating(const std::string& s) : DemoDelegating(std::stoi(s))
{}
};
#endif
#if 1
class DemoInit final
{
private:
int a = 0;
std::string s = "hello";
std::vector<int> v{1, 2, 3};
public:
DemoInit() = default;
~DemoInit() = default;
public:
DemoInit(int x) : a(x) {}
};
#endif
int main()
{
using namespace std;
cout << "show your class." << endl;
}