Cpp_part8

Cpp_part8

Charles Lv7

Cpp_part8

STL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// template 动态增长万能模板
void test01() {
vector<int> v;
for (int i = 0; i < 10; i++)
v.push_back(i);
cout << v[3] << endl;
// iterator 迭代器模式
vector<int>::iterator it = v.begin();
while (it != v.end()) {
cout << *it << endl;
it++;
}
// iterator 对各容器通用
}

Pre oo Summary

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
/*
OO based-on CPP:
1).封装:
struct class
data + function
access control(private public protected)
this
construct/destruct
reference/copy constructor
static
const
2).继承
共性与特性 is a
多重继承(X)
不要削弱父类接口
构造顺序(先调父类构造,析构相反)
3).多态(编译原理)
向上类型转换
runtime binding(动态绑定)[前绑定和后绑定]
virtual v-table v-ptr
高级抽象:
1).抽象类
2).接口
*/

// 性能问题出现之前不考虑性能

Main part

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <bits/stdc++.h>
using namespace std;
#include "NewClass.h"
using namespace Myclass;
//类似于JAVA的package
#define M 100007
#define N 1007
#define INF 0x3f3f3f3f
#define ll long long
#define db double
// Facade 外观模式
int main() {
test01();
return 0;
}

//NewClass.h
namespace Myclass {
class Test {};
} // namespace Myclass
  • Title: Cpp_part8
  • Author: Charles
  • Created at : 2022-12-28 08:42:27
  • Updated at : 2023-02-09 17:57:26
  • Link: https://charles2530.github.io/2022/12/28/cpp-part8/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments