Skip to content

Commit 4f149ee

Browse files
committed
update
1 parent 3ae20ae commit 4f149ee

38 files changed

+1770
-9
lines changed

.README.md.un~

24.7 KB
Binary file not shown.

README.md

+24-9
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434

3535
---
3636

37-
#### 拓展部分:
38-
39-
- [C++中如何将string类型转换为int类型?](./basic_content/extent/string_int.md)
4037

4138
### 2.进阶部分
4239

@@ -131,12 +128,30 @@ for(decl:col) {
131128

132129
#### 3.1 [极客时间《现代C++实战30讲》](https://time.geekbang.org/channel/home)
133130

134-
- [堆、栈、RAII:C++里该如何管理资源?](./morden_C++_30)
135-
- [](./morden_C++_30/RAII/heap.cpp)
136-
- [](./morden_C++_30/RAII/stack.cpp)
137-
- [RAII](./morden_C++_30/RAII/RAII.cpp)
131+
- [堆、栈、RAII:C++里该如何管理资源?](./modern_C++_30)
132+
- [](./modern_++_30/RAII/heap.cpp)
133+
- [](./modern_C++_30/RAII/stack.cpp)
134+
- [RAII](./modern_C++_30/RAII/RAII.cpp)
135+
136+
137+
138+
### 4.拓展部分
139+
140+
#### 4.1 [C++惯用法](./codingStyleIdioms)
141+
142+
##### 你最喜欢的c++编程风格惯用法是什么?
143+
144+
- [1.类初始化列表](./codingStyleIdioms/1_classInitializers)
145+
- [2.枚举类替换命名空间](./codingStyleIdioms/2_enumclass_namespace)
146+
- [3.RAII(资源获取即初始化)](./codingStyleIdioms/3_RAII)
147+
- [4.copy and swap](./codingStyleIdioms/4_copy-swap)
148+
- [5.pImpl(指针指向具体实现)](./codingStyleIdioms/5_pImpl)
149+
150+
#### 4.2 一些问题
151+
152+
- [C++中如何将string类型转换为int类型?](./basic_content/extent/string_int.md)
138153

139-
### 4.代码运行
154+
### 5.代码运行
140155

141156
- **代码环境**
142157

@@ -146,7 +161,7 @@ Ubuntu 18.04
146161

147162
CLion gcc/g++
148163

149-
### 5.关于作者:
164+
### 6.关于作者:
150165

151166
个人公众号:
152167

README.md~

+169
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# C++那些事
2+
3+
### 0.项目概要
4+
5+
学习C++内容,包括理论、源码、实践、课程代码、项目等
6+
7+
### 1.基础部分
8+
9+
- [const那些事](./basic_content/const)
10+
- [static那些事](./basic_content/static)
11+
- [this那些事](./basic_content/this)
12+
- [inline那些事](./basic_content/inline)
13+
- [sizeof那些事](./basic_content/sizeof)
14+
- [函数指针那些事](./basic_content/func_pointer)
15+
- [纯虚函数和抽象类那些事](./basic_content/abstract)
16+
- [vptr_vtable那些事](./basic_content/vptr_vtable)
17+
- [virtual那些事](./basic_content/virtual)
18+
- [volatile那些事](./basic_content/volatile)
19+
- [assert那些事](./basic_content/assert)
20+
- [位域那些事](./basic_content/bit)
21+
- [extern那些事](./basic_content/extern)
22+
- [struct那些事](./basic_content/struct)
23+
- [struct与class那些事](./basic_content/struct_class)
24+
- [union那些事](./basic_content/union)
25+
- [c实现c++多态那些事](./basic_content/c_poly)
26+
- [explicit那些事](./basic_content/explicit)
27+
- [friend那些事](./basic_content/friend)
28+
- [using那些事](./basic_content/using)
29+
- [::那些事](./basic_content/::)
30+
- [enum那些事](./basic_content/enum)
31+
- [decltype那些事](./basic_content/decltype)
32+
- [引用与指针那些事](./basic_content/pointer_refer)
33+
- [宏那些事](./basic_content/macro)
34+
35+
---
36+
37+
38+
### 2.进阶部分
39+
40+
#### 2.1 [effective_c++](./effective_c++)
41+
42+
正在更新...
43+
44+
#### 2.2 [C++2.0新特性](./c++2.0/)
45+
46+
- [Variadic Templates](./c++2.0/variadic)
47+
- Spaces in Template Expressions
48+
49+
```cpp
50+
vector<list<int> > //ok in each C++ version
51+
vector<list<int>> // before c++ 11 error error: ‘>>’ should be ‘> >’ within a nested template argument list,c++11后可以正常通过
52+
```
53+
54+
- [nullptr and nullptr_t](./c++2.0/nullptr.cpp)
55+
- [Automatic Type Deduction with auto](./c++2.0/auto.cpp)
56+
- [Uniform Initialization ](./c++2.0/uniform_initialization.cpp)
57+
- [initializer_list](./c++2.0/initializer.cpp)
58+
- [explicit for ctors taking more than one argument](./c++2.0/explicit.cpp)
59+
- [range-based for statement](./c++2.0/auto.cpp)
60+
61+
```cpp
62+
for(decl:col) {
63+
statement
64+
}
65+
```
66+
67+
- [=default,=delete](./c++2.0/default_delete.cpp)
68+
69+
如果你自行定义了一个ctor,那么编译器就不会给你一个default ctor
70+
如果强制加上=default,就可以重新获得并使用default ctor.
71+
72+
- Alias(化名)Template(template typedef)
73+
74+
[alias.cpp](./c++2.0/alias.cpp)
75+
76+
[template_template.cpp](./c++2.0/template_template.cpp)
77+
78+
- [template template parameter](./c++2.0/template_template.cpp)
79+
- [type alias](./c++2.0/type_alias.cpp)
80+
- [noexcept](./c++2.0/noexcept.cpp)
81+
- [override](./c++2.0/override.cpp)
82+
- [final](./c++2.0/final.cpp)
83+
- [decltype](./c++2.0/decltype.cpp)
84+
- [lambda](./c++2.0/lambda.cpp)
85+
- [Rvalue reference](./c++2.0/rvalue.cpp)
86+
- [move aware class](./c++2.0/move.cpp)
87+
- 容器-结构与分类
88+
89+
(1) 序列式容器包括:array(C++2.0新引入),vector,deque,list,forward_list(C++2.0新引入)
90+
91+
(2) 关联式容器包括:set/multiset,map/multimap
92+
93+
(3) 无序容器(C++2.0新引入,更换原先hash_xxx为unordered_xxx)包括:unordered_map/unordered_multimap,unordered_set/unordered_multiset
94+
95+
- [Hash Function](./c++2.0/hash.cpp)
96+
- [tuple](./c++2.0/tuple.cpp)
97+
98+
学习资料:https://www.bilibili.com/video/av51863195?from=search&seid=3610634846288253061
99+
100+
#### 2.3 [C++并发编程v1](./c++2.0/./concurrency_v1)
101+
102+
- [第一章](./c++2.0/./concurrency_v1/chapter1)
103+
- [第二章](./c++2.0/./concurrency_v1/chapter2)
104+
105+
学习资料:https://chenxiaowei.gitbook.io/cpp_concurrency_in_action/
106+
107+
#### 2.4 [STL源码剖析](./stl_src)
108+
109+
**stl源码剖析:gcc4.9.1**
110+
111+
- [array](./stl_src/array.md)
112+
- [deque](./stl_src/deque.md)
113+
- [queue and stack](./stl_src/queue_stack.md)
114+
- [list](./stl_src/list.md)
115+
- [vector](./stl_src/vector.md)
116+
- [typename](./stl_src/typename.md)
117+
- [traits](./stl_src/traits.md)
118+
- [iterator](./stl_src/iterator.md)
119+
- [谈谈STL设计之EBO优化](./stl_src/谈谈STL设计之EBO优化.md)
120+
- [rb_tree](./stl_src/rb_tree.md)
121+
- [set and multiset](set_multiset.md)
122+
- [map and multimap](./stl_src/map_multimap.md)
123+
- [hashtable](./stl_src/hashtable.md)
124+
- [myhashtable](./stl_src/myhashtable.md)
125+
- [unordered_map](./stl_src/unordered_map.md)
126+
127+
### 3.学习课程
128+
129+
#### 3.1 [极客时间《现代C++实战30讲》](https://time.geekbang.org/channel/home)
130+
131+
- [堆、栈、RAII:C++里该如何管理资源?](./modern_C++_30)
132+
- [堆](./modern_++_30/RAII/heap.cpp)
133+
- [栈](./modern_C++_30/RAII/stack.cpp)
134+
- [RAII](./modern_C++_30/RAII/RAII.cpp)
135+
136+
137+
138+
### 4.拓展部分
139+
140+
#### 4.1 [C++惯用法](./codingStyleIdioms)
141+
142+
##### 你最喜欢的c++编程风格惯用法是什么?
143+
144+
- [1.类初始化列表](./codingStyleIdioms/1_classInitializers)
145+
- [2.枚举类替换命名空间](./codingStyleIdioms/2_enumclass_namespace)
146+
- [3.RAII(资源获取即初始化)](./codingStyleIdioms/3_RAII)
147+
- [4.copy and swap](./codingStyleIdioms/4_copy-swap)
148+
- [5.pImpl(指针指向具体实现)](./codingStyleIdioms/5_pImpl)
149+
150+
#### 4.2 一些问题
151+
152+
- [C++中如何将string类型转换为int类型?](./basic_content/extent/string_int.md)
153+
154+
### 5.代码运行
155+
156+
- **代码环境**
157+
158+
Ubuntu 18.04
159+
160+
- **工具**
161+
162+
CLion gcc/g++
163+
164+
### 6.关于作者:
165+
166+
个人公众号:
167+
168+
![](./img/wechat.jpg)
169+

codingStyleIdioms/.README.md.swp

12 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//
2+
// Created by light on 19-12-9.
3+
//
4+
5+
#include <iostream>
6+
7+
class Animal {
8+
public:
9+
Animal() {
10+
std::cout << "Animal() is called" << std::endl;
11+
}
12+
13+
Animal(const Animal &) {
14+
std::cout << "Animal (const Animal &) is called" << std::endl;
15+
}
16+
17+
Animal &operator=(const Animal &) {
18+
std::cout << "Animal & operator=(const Animal &) is called" << std::endl;
19+
return *this;
20+
}
21+
22+
~Animal() {
23+
std::cout << "~Animal() is called" << std::endl;
24+
}
25+
};
26+
27+
class Dog {
28+
public:
29+
// 第一种: 使用初始化列表。
30+
Dog(const Animal &animal) : __animal(animal) {
31+
std::cout << "Dog(const Animal &animal) is called" << std::endl;
32+
}
33+
// 第二种:构造函数赋值来初始化对象。
34+
// Dog(const Animal &animal) {
35+
// __animal = animal;
36+
// std::cout << "Dog(const Animal &animal) is called" << std::endl;
37+
// }
38+
~Dog() {
39+
std::cout << "~Dog() is called" << std::endl;
40+
}
41+
42+
private:
43+
Animal __animal;
44+
};
45+
46+
int main() {
47+
Animal animal;
48+
std::cout << std::endl;
49+
Dog d(animal);
50+
std::cout << std::endl;
51+
return 0;
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// Created by light on 19-12-9.
3+
//
4+
#include <iostream>
5+
class Animal {
6+
public:
7+
Animal(int age) {
8+
std::cout << "Animal(int age) is called" << std::endl;
9+
}
10+
11+
Animal(const Animal & animal) {
12+
std::cout << "Animal (const Animal &) is called" << std::endl;
13+
}
14+
15+
Animal &operator=(const Animal & amimal) {
16+
std::cout << "Animal & operator=(const Animal &) is called" << std::endl;
17+
return *this;
18+
}
19+
20+
~Animal() {
21+
std::cout << "~Animal() is called" << std::endl;
22+
}
23+
24+
};
25+
26+
class Dog : Animal {
27+
public:
28+
Dog(int age) : Animal(age) {
29+
std::cout << "Dog(int age) is called" << std::endl;
30+
}
31+
32+
~Dog() {
33+
std::cout << "~Dog() is called" << std::endl;
34+
}
35+
};
36+
37+
int main() {
38+
Animal animal(10);
39+
std::cout << std::endl;
40+
Dog d(100);
41+
std::cout << std::endl;
42+
return 0;
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// Created by light on 19-12-9.
3+
//
4+
5+
#include <iostream>
6+
7+
class Animal {
8+
public:
9+
Animal(int age,std::string name):age_(age),name_(name) {
10+
std::cout << "Animal(int age) is called" << std::endl;
11+
}
12+
private:
13+
int &age_;
14+
const std::string name_;
15+
};
16+
17+
int main() {
18+
Animal animal(10,"hh");
19+
return 0;
20+
}

0 commit comments

Comments
 (0)