+
+/// Define a pointer of function
+typedef void (*pf) ();
+
+/**
+ * @brief parent class
+ */
+typedef struct _A
+{
+ pf _f;
+}A;
+
+
+/**
+ * @brief child class
+ */
+typedef struct _B
+{
+ A _b; ///< The inheritance of the parent class can be realized by defining an object of the base class in the subclass
+}B;
+
+void FunA()
+{
+ printf("%s\n","Base A::fun()");
+}
+
+void FunB()
+{
+ printf("%s\n","Derived B::fun()");
+}
+
+
+int main()
+{
+ A a;
+ B b;
+
+ a._f = FunA;
+ b._b._f = FunB;
+
+ A *pa = &a;
+ pa->_f();
+ pa = (A *)&b; /// The parent class pointer points to the object of the subclass. Because of the type mismatch, it needs to be forced
+ pa->_f();
+ return 0;
+}
diff --git a/english/basic_content/const/README.md b/english/basic_content/const/README.md
new file mode 100644
index 0000000..f324abc
--- /dev/null
+++ b/english/basic_content/const/README.md
@@ -0,0 +1,382 @@
+
+
+
+## 1.The Definition Of const
+
+Const type is that people use type specifier **const** signiture type to demonstrate,const variables or objects can not be updated。
+
+## 2. Effect Of Const
+
+(1)define variable
+
+```
+const int a=100;
+```
+
+(2) check type
+
+The difference between const variable and define variable: ~~**Constants have types, which can be checked by the compiler; the define macro definition has no data type, it is just a simple string replacement, and cannot be checked for security
+**~~ Thanks for point this bug out.
+> https://github.com/Light-City/CPlusPlusThings/issues/5
+
+Only variables of type integer or enumeration are defined by `const`. In other cases, it is only a 'const' qualified variable and should not be confused with constants.
+
+(3)prevent modification, protect and increase program robustness
+
+
+```
+void f(const int i){
+ i++; //error!
+}
+```
+(4)Save space and avoid unnecessary memory allocation
+
+From the compile point of view, the variables can be defined by const only give the corresponding memory address. Meanwhile the #define gives an immediate number.
+
+## 3.const object is the file local variable by default
+
+
+Attention:not const will be set as extern by default.For the const variable to be accessible in other files, it must be explicitly specified as extern in the file
+
+
+> Access of variables not modified by const in different files
+
+
+```
+// file1.cpp
+int ext
+// file2.cpp
+#include
+/**
+ * by 光城
+ * compile: g++ -o file file2.cpp file1.cpp
+ * execute: ./file
+ */
+extern int ext;
+int main(){
+ std::cout<<(ext+10)<
+using namespace std;
+int main(){
+
+ int num=0;
+ int * const ptr=# //const指针必须初始化!且const指针的值不能修改
+ int * t = #
+ *t = 1;
+ cout<<*ptr<
+using namespace std;
+int main(){
+ const int num=0;
+ int * const ptr=# //error! const int* -> int*
+ cout<<*ptr<
+#include"apple.cpp"
+using namespace std;
+
+Apple::Apple(int i):apple_number(i)
+{
+
+}
+int Apple::add(int num){
+ take(num);
+}
+int Apple::add(int num) const{
+ take(num);
+}
+void Apple::take(int num) const
+{
+ cout<<"take func "<
+#include"apple.cpp"
+using namespace std;
+Apple::Apple(int i)
+{
+
+}
+int Apple::add(int num){
+ take(num);
+}
+int Apple::add(int num) const{
+ take(num);
+}
+void Apple::take(int num) const
+{
+ cout<<"take func "<
+#include"apple.cpp"
+using namespace std;
+
+Apple::Apple(int i):apple_number(i)
+{
+
+}
+int Apple::add(int num){
+ take(num);
+}
+int Apple::add(int num) const{
+ take(num);
+}
+void Apple::take(int num) const
+{
+ cout<<"take func "<
+#include"apple.cpp"
+using namespace std;
+const int Apple::apple_number=10;
+Apple::Apple(int i)
+{
+
+}
+int Apple::add(int num){
+ take(num);
+}
+int Apple::add(int num) const{
+ take(num);
+}
+void Apple::take(int num) const
+{
+ cout<<"take func "<
+#include"apple.cpp"
+using namespace std;
+const int Apple::apple_number=10;
+int Apple::ap=666;
+Apple::Apple(int i)
+{
+
+}
+int Apple::add(int num){
+ take(num);
+}
+int Apple::add(int num) const{
+ take(num);
+}
+void Apple::take(int num) const
+{
+ cout<<"take func "<
+using namespace std;
+
+void f(const int i){
+ i=10; // error: assignment of read-only parameter ‘i’
+ cout<
+using namespace std;
+int main(){
+ const int b = 10;
+ b = 0; //error
+ const string s = "helloworld";
+ const int i,j=0;
+}
diff --git a/english/basic_content/const/extern_const/const_file1.cpp b/english/basic_content/const/extern_const/const_file1.cpp
new file mode 100644
index 0000000..7077ac9
--- /dev/null
+++ b/english/basic_content/const/extern_const/const_file1.cpp
@@ -0,0 +1 @@
+extern const int ext=12;
diff --git a/english/basic_content/const/extern_const/const_file2.cpp b/english/basic_content/const/extern_const/const_file2.cpp
new file mode 100644
index 0000000..53729f4
--- /dev/null
+++ b/english/basic_content/const/extern_const/const_file2.cpp
@@ -0,0 +1,11 @@
+#include
+/**
+ * by 光城
+ * compile: g++ -o file const_file2.cpp const_file1.cpp
+ * execute: ./file
+ */
+extern const int ext;
+int main(){
+
+ std::cout<
+/**
+ * by 光城
+ * compile: g++ -o file file2.cpp file1.cpp
+ * execute: ./file
+ */
+extern int ext;
+int main(){
+
+ std::cout<<(ext+10)<
+using namespace std;
+
+
+int main(){
+ const int *ptr;
+ *ptr=10; //error
+}
diff --git a/english/basic_content/const/funciton_const/condition1/condition2.cpp b/english/basic_content/const/funciton_const/condition1/condition2.cpp
new file mode 100644
index 0000000..9db7339
--- /dev/null
+++ b/english/basic_content/const/funciton_const/condition1/condition2.cpp
@@ -0,0 +1,9 @@
+#include
+using namespace std;
+
+
+int main(){
+ const int p = 10;
+ const void *vp = &p;
+ void *vp = &p; //error
+}
diff --git a/english/basic_content/const/funciton_const/condition1/condition3.cpp b/english/basic_content/const/funciton_const/condition1/condition3.cpp
new file mode 100644
index 0000000..5809e5f
--- /dev/null
+++ b/english/basic_content/const/funciton_const/condition1/condition3.cpp
@@ -0,0 +1,12 @@
+#include
+using namespace std;
+
+int main(){
+ const int *ptr;
+ int val = 3;
+ ptr = &val; //ok
+ int *ptr1 = &val;
+ *ptr1=4;
+ cout<<*ptr<
+using namespace std;
+int main(){
+
+ int num=0;
+ int * const ptr=# //const指针必须初始化!且const指针的值不能修改
+ int * t = #
+ *t = 1;
+ cout<<*ptr<
+using namespace std;
+int main(){
+
+ const int num=0;
+ int * const ptr=# //error! const int* -> int*
+ cout<<*ptr<
+using namespace std;
+int main(){
+
+ const int num=10;
+ const int * const ptr=# //error! const int* -> int*
+ cout<<*ptr<
+using namespace std;
+
+int main(){
+
+ const int p = 3;
+ const int * const ptr = &p;
+ cout<<*ptr<vec;
+typedef decltype(vec.begin()) vectype;
+for (vectype i = vec.begin; i != vec.end(); i++)
+{
+//...
+}
+```
+
+like auto, improves the readability of the code.
+
+
+### 1.3 Reuse anonymous types
+
+In C + +, we sometimes encounter some anonymous types, such as:
+
+```c++
+struct
+{
+ int d ;
+ doubel b;
+}anon_s;
+```
+
+With decltype, we can reuse this anonymous structure:
+```c++
+decltype(anon_s) as ;//Defines an anonymous structure above
+```
+
+### 1.4 In generic programming, auto is used to trace the return value type of function
+
+
+```c++
+template
+auto multiply(T x, T y)->decltype(x*y)
+{
+ return x*y;
+}
+```
+
+Code:[decltype.cpp](decltype.cpp)
+
+## 2.Discriminant rules
+
+
+
+For decltype (E), the results are affected by the following conditions:
+If e is a marker expression or class member access expression without parentheses, decltype (E) of is the type of entity named by E.In addition, if e is an overloaded function, it will result in compilation errors.
+Otherwise, assume that the type of E is t, and if e is a dying value, then decltype (E) is t&&
+Otherwise, assume that the type of E is t, and if e is a dying value, then decltype (E) is t&&
+Otherwise, assuming that the type of E is t, decltype (E) is t.
+
+Markers are defined by programmers except for keywords, literals and other tags that the compiler needs to use. The expression corresponding to a single marker is a marker expression. For example:
+
+```c++
+int arr[4]
+```
+Then arr is a marker expression,ranther than arr[3]+0
+
+Example:
+
+```c++
+int i = 4;
+int arr[5] = { 0 };
+int *ptr = arr;
+struct S{ double d; }s ;
+void Overloaded(int);
+void Overloaded(char);// reload function
+int && RvalRef();
+const bool Func(int);
+
+//Rule 1: derivation is its type
+decltype (arr) var1; //int 标记符表达式
+
+decltype (ptr) var2;//int * 标记符表达式
+
+decltype(s.d) var3;//doubel 成员访问表达式
+
+//decltype(Overloaded) var4;//重载函数。编译错误。
+
+//规则二:将亡值。推导为类型的右值引用。
+
+decltype (RvalRef()) var5 = 1;
+
+//规则三:Lvalue, derived as a reference to the type
+
+decltype ((i))var6 = i; //int&
+
+decltype (true ? i : i) var7 = i; //int& A conditional expression returns an lvalue
+
+decltype (++i) var8 = i; //int& ++i返回i的左值。
+
+decltype(arr[5]) var9 = i;//int&. []操作返回左值
+
+decltype(*ptr)var10 = i;//int& *操作返回左值
+
+decltype("hello")var11 = "hello"; //const char(&)[9] 字符串字面常量为左值,且为const左值。
+
+
+//Rule 4: if none of the above is true, this type is derived
+
+decltype(1) var12;//const int
+
+decltype(Func(1)) var13=true;//const bool
+
+decltype(i++) var14 = i;//int i++返回右值
+```
+
+From:https://www.cnblogs.com/QG-whz/p/4952980.html
diff --git a/english/basic_content/decltype/decltype b/english/basic_content/decltype/decltype
new file mode 100755
index 0000000..fb9f578
Binary files /dev/null and b/english/basic_content/decltype/decltype differ
diff --git a/english/basic_content/decltype/decltype.cpp b/english/basic_content/decltype/decltype.cpp
new file mode 100644
index 0000000..4bf9876
--- /dev/null
+++ b/english/basic_content/decltype/decltype.cpp
@@ -0,0 +1,60 @@
+/**
+ * @file decltype.cpp
+ * @brief g++ -o decltype decltype.cpp -std=c++11
+ * @author 光城
+ * @version v1
+ * @date 2019-08-08
+ */
+
+#include
+#include
+using namespace std;
+/**
+ * 泛型编程中结合auto,用于追踪函数的返回值类型
+ */
+template
+
+auto multiply(T x, T y)->decltype(x*y)
+{
+ return x*y;
+}
+
+int main()
+{
+ int nums[] = {1,2,3,4};
+ vector vec(nums,nums+4);
+ vector::iterator it;
+
+ for(it=vec.begin();it!=vec.end();it++)
+ cout<<*it<<" ";
+ cout<
+using namespace std;
+
+enum Color {RED,BLUE};
+enum Feeling {EXCITED,BLUE};
+
+int main()
+{
+ return 0;
+}
+```
+- Implicit conversion to int
+
+- The actual type used to represent an enumerated variable cannot be explicitly specified, Therefore, forward declaration of enumeration types cannot be supported.
+Implementation:[tradition_color.cpp](tradition_color.cpp)
+
+## Classic Method
+
+A simple way to solve the problem of naming conflicts caused by unlimited scope is to prefix the enumeration variables. Change the above example to COLOR_BLUE and FEELING_BLUE。
+
+Generally speaking, we usually prefix all constants for uniformity.But the code for defining enumeration variables is cumbersome.This may have to be done in the C program. But C++ coder do not like this method。Alternatives is namespace:
+```c++
+namespace Color
+{
+ enum Type
+ {
+ RED=15,
+ YELLOW,
+ BLUE
+ };
+};
+```
+
+Then you can use `Color::Type c = Color::RED;` to define the new enumeration。If after`using namespace Color` ,the prefix can also be omitted to simplify the code.However, the scope closure provided by a namespace is not high because it can be subsequently extended.In large projects, it is still possible for different people to give different things the same enumeration type names.
+
+A more "effective" approach is to limit its scope with a class or struct.For example:The new variable is defined in the same way as in the namespace above. This way, you don't have to worry about the class being modified elsewhere.We use structs instead of classes because we want these constants to be publicly accessible.
+
+```c++
+struct Color1
+{
+ enum Type
+ {
+ RED=102,
+ YELLOW,
+ BLUE
+ };
+};
+```
+
+Implementation:[classic_practice.cpp](classic_practice.cpp)
+
+## C++11 Enum class
+
+The above approach solves the first problem, but it can not do anything for the latter two.Fortunately,C ++ 11 standard introduces enum class. It can solve the above problems.
+
+- The scope of the new enum is no longer global
+
+- Cannot be implicitly converted to another type
+
+
+```c++
+/**
+ * @brief C++11 enum class
+ * Equals to enum class Color2:int
+ */
+enum class Color2
+{
+ RED=2,
+ YELLOW,
+ BLUE
+};
+r2 c2 = Color2::RED;
+cout << static_cast(c2) << endl; //!
+```
+
+- You can specify a specific type to store enum
+
+```c++
+enum class Color3:char; // Forward statement
+
+// Definition
+enum class Color3:char
+{
+ RED='r',
+ BLUE
+};
+char c3 = static_cast(Color3::RED);
+```
+
+Implementation:[classic_practice.cpp](classic_practice.cpp)
+
+## Enum types in class
+
+
+
+Sometimes we want certain constants to work only in classes. Because the macro constant defined by a is global, it can not achieve the purpose, so we want to use const to modify data members.The const data member does exist, but its meaning is not what we expected.
+Data members are constants only for the lifetime of an objec. However, it is variable for the whole class, because the class can create multiple objects, and the values of const data members of different objects can be different.
+
+
+
+Cannot be initialized in a class declaration const data memeber。The following usage is incorrect,Because the compiler does not know what the value of size is when the object of the class is not created.(c++11)
+
+```c++
+class A
+{
+ const int SIZE = 100; // Error,Attempt to initialize const data member in class declaration
+ int array[SIZE]; // Error,Unknown size
+};
+```
+
+This should be done in the initialization list of the class's constructor:
+
+```c++
+class A
+{
+ A(int size); // Constructor
+ const int SIZE ;
+};
+A::A(int size) : SIZE(size) // The definition of Struct
+{
+
+}
+A a(100); // The size of Object A is 100
+A b(200); // The size of Object B is 200
+```
+
+How can I establish constants that are constant throughout a class?
+
+It should be implemented with enumeration constants in the class. Such as:
+
+```c++
+class Person{
+public:
+ typedef enum {
+ BOY = 0,
+ GIRL
+ }SexType;
+};
+//Access via Person::BOY or Person::GIRL.
+```
+
+Enum constants do not take up the storage space of the object . They are all evaluated at compile time
+
+
+Drawback of Enum:Its implied data type is an integer, the maximum is limited, and it cannot represent floating point.
diff --git a/english/basic_content/enum/classic_practice b/english/basic_content/enum/classic_practice
new file mode 100755
index 0000000..f9f67b7
Binary files /dev/null and b/english/basic_content/enum/classic_practice differ
diff --git a/english/basic_content/enum/classic_practice.cpp b/english/basic_content/enum/classic_practice.cpp
new file mode 100644
index 0000000..f831521
--- /dev/null
+++ b/english/basic_content/enum/classic_practice.cpp
@@ -0,0 +1,87 @@
+/**
+ * @file classic_practice.cpp
+ * @brief g++ -o classic_practice classic_practice.cpp -std=c++11
+ * @author 光城
+ * @version v1
+ * @date 2019-08-07
+ */
+
+#include
+using namespace std;
+/**
+ * @brief namespace解决作用域不受限
+ */
+namespace Color
+{
+ enum Type
+ {
+ RED=15,
+ YELLOW,
+ BLUE
+ };
+};
+
+/**
+ * @brief 上述如果 using namespace Color 后,前缀还可以省去,使得代码简化。
+ * 不过,因为命名空间是可以随后被扩充内容的,所以它提供的作用域封闭性不高。
+ * 在大项目中,还是有可能不同人给不同的东西起同样的枚举类型名。
+ * 更“有效”的办法是用一个类或结构体来限定其作用域。
+ *
+ * 定义新变量的方法和上面命名空间的相同。
+ * 不过这样就不用担心类在别处被修改内容。
+ * 这里用结构体而非类,一是因为本身希望这些常量可以公开访问,
+ * 二是因为它只包含数据没有成员函数。
+ */
+struct Color1
+{
+ enum Type
+ {
+ RED=102,
+ YELLOW,
+ BLUE
+ };
+};
+
+/**
+ * @brief C++11的枚举类
+ * 下面等价于enum class Color2:int
+ */
+enum class Color2
+{
+ RED=2,
+ YELLOW,
+ BLUE
+};
+
+enum class Color3:char; // 前向声明
+
+// 定义
+enum class Color3:char
+{
+ RED='r',
+ BLUE
+};
+
+int main()
+{
+ // 定义新的枚举变量
+ Color::Type c = Color::RED;
+ cout<(c2) << endl;
+
+ char c3 = static_cast(Color3::RED);
+ cout<
+using namespace std;
+
+enum Color {RED,BLUE};
+enum Feeling {EXCITED,BLUE};
+
+int main()
+{
+ return 0;
+}
diff --git a/english/basic_content/explicit/README.md b/english/basic_content/explicit/README.md
new file mode 100644
index 0000000..58c3b45
--- /dev/null
+++ b/english/basic_content/explicit/README.md
@@ -0,0 +1,15 @@
+# Things about explicit
+
+## About Author:
+
+
+
+
+- explicit When decorating a constructor, you can prevent implicit conversion and copy initialization
+- explicit When modifying a conversion function, you can prevent implicit conversion, except for context conversion
+
+
+Code :[.explicit.cpp](./explicit.cpp)
+
+Reference Link:
+> https://stackoverflow.com/questions/4600295/what-is-the-meaning-of-operator-bool-const
diff --git a/english/basic_content/explicit/explicit b/english/basic_content/explicit/explicit
new file mode 100755
index 0000000..ab3a412
Binary files /dev/null and b/english/basic_content/explicit/explicit differ
diff --git a/english/basic_content/explicit/explicit.cpp b/english/basic_content/explicit/explicit.cpp
new file mode 100644
index 0000000..f659635
--- /dev/null
+++ b/english/basic_content/explicit/explicit.cpp
@@ -0,0 +1,46 @@
+#include
+
+using namespace std;
+
+struct A
+{
+ A(int) { }
+ operator bool() const { return true; }
+};
+
+struct B
+{
+ explicit B(int) {}
+ explicit operator bool() const { return true; }
+};
+
+void doA(A a) {}
+
+void doB(B b) {}
+
+int main()
+{
+ A a1(1); // OK:直接初始化
+ A a2 = 1; // OK:复制初始化
+ A a3{ 1 }; // OK:直接列表初始化
+ A a4 = { 1 }; // OK:复制列表初始化
+ A a5 = (A)1; // OK:允许 static_cast 的显式转换
+ doA(1); // OK:允许从 int 到 A 的隐式转换
+ if (a1); // OK:使用转换函数 A::operator bool() 的从 A 到 bool 的隐式转换
+ bool a6(a1); // OK:使用转换函数 A::operator bool() 的从 A 到 bool 的隐式转换
+ bool a7 = a1; // OK:使用转换函数 A::operator bool() 的从 A 到 bool 的隐式转换
+ bool a8 = static_cast(a1); // OK :static_cast 进行直接初始化
+
+ B b1(1); // OK:直接初始化
+// B b2 = 1; // 错误:被 explicit 修饰构造函数的对象不可以复制初始化
+ B b3{ 1 }; // OK:直接列表初始化
+// B b4 = { 1 }; // 错误:被 explicit 修饰构造函数的对象不可以复制列表初始化
+ B b5 = (B)1; // OK:允许 static_cast 的显式转换
+// doB(1); // 错误:被 explicit 修饰构造函数的对象不可以从 int 到 B 的隐式转换
+ if (b1); // OK:被 explicit 修饰转换函数 B::operator bool() 的对象可以从 B 到 bool 的按语境转换
+ bool b6(b1); // OK:被 explicit 修饰转换函数 B::operator bool() 的对象可以从 B 到 bool 的按语境转换
+// bool b7 = b1; // 错误:被 explicit 修饰转换函数 B::operator bool() 的对象不可以隐式转换
+ bool b8 = static_cast(b1); // OK:static_cast 进行直接初始化
+
+ return 0;
+}
diff --git a/english/basic_content/extern/README.md b/english/basic_content/extern/README.md
new file mode 100644
index 0000000..8402ad6
--- /dev/null
+++ b/english/basic_content/extern/README.md
@@ -0,0 +1,195 @@
+# extern "C"
+
+## About Author:
+
+
+
+
+## 1. Compiler difference between C and C ++
+
+In C + +, we often see extern "C" modifier function in the header file. What's the effect. Is a function defined in C language module for C + + link.
+
+Although C + + is compatible with C, the symbols generated by function compilation in C + + files are different from those generated by C language.Because C + + supports function overloading, the symbols generated by C + + function compilation have the information of function parameter type, while C does not.
+
+
+Take `int add(int a, int b)` for example. The C + + compiler generates the. O file, `add` becomes `add_int_int` and so on, while C would be like this `_add`, that is:For the same function, in C and C + +, the symbols generated after compilation are different.
+
+This leads to a problem: if the function implemented in C + + is implemented in C language, an error will occur when compiling the link, indicating that the corresponding symbol cannot be found. At this time`extern "C"` works:Tell the linker to find its `_ C `language symbols such as `add` are not modified by C ++.
+
+## 2.C ++ calls C functions
+
+When referring to the header file of C, you need to add `extern "C"`
+
+```c++
+//add.h
+#ifndef ADD_H
+#define ADD_H
+int add(int x,int y);
+#endif
+
+//add.c
+#include "add.h"
+
+int add(int x,int y) {
+ return x+y;
+}
+
+//add.cpp
+#include
+#include "add.h"
+using namespace std;
+int main() {
+ add(2,3);
+ return 0;
+}
+```
+
+Compile:
+
+```
+//Generate add.o file
+gcc -c add.c
+```
+
+Link:
+
+```
+g++ add.cpp add.o -o main
+```
+
+Without extern "C":
+
+```c++
+> g++ add.cpp add.o -o main
+add.o:在函数‘main’中:
+add.cpp:(.text+0x0): `main'被多次定义
+/tmp/ccH65yQF.o:add.cpp:(.text+0x0):第一次在此定义
+/tmp/ccH65yQF.o:在函数‘main’中:
+add.cpp:(.text+0xf):对‘add(int, int)’未定义的引用
+add.o:在函数‘main’中:
+add.cpp:(.text+0xf):对‘add(int, int)’未定义的引用
+collect2: error: ld returned 1 exit status
+```
+
+With extern "C":
+
+`add.cpp`
+
+```c++
+#include
+using namespace std;
+extern "C" {
+ #include "add.h"
+}
+int main() {
+ add(2,3);
+ return 0;
+}
+```
+When compiling, you must pay attention to generating intermediate files add.o through GCC
+
+
+```
+gcc -c add.c
+```
+
+Compile:
+
+```
+g++ add.cpp add.o -o main
+```
+
+Code:
+
+- [add.h](extern_c++/add.h)
+
+- [add.c](extern_c++/add.c)
+
+- [add.cpp](extern_c++/add.cpp)
+
+## 2.Calling C++ function in C
+
+
+`extern "C"` It is a syntax error in C, which needs to be put in the C + + header file.
+
+```c
+// add.h
+#ifndef ADD_H
+#define ADD_H
+extern "C" {
+ int add(int x,int y);
+}
+#endif
+
+// add.cpp
+#include "add.h"
+
+int add(int x,int y) {
+ return x+y;
+}
+
+// add.c
+extern int add(int x,int y);
+int main() {
+ add(2,3);
+ return 0;
+}
+```
+
+Compile:
+
+```c
+g++ -c add.cpp
+```
+
+Link:
+
+```
+gcc add.c add.o -o main
+```
+
+Code:
+
+- [add.h](extern_c/add.h)
+
+- [add.c](extern_c/add.c)
+
+- [add.cpp](extern_c/add.cpp)
+
+In the header file of C language, the external function can only be specified as extern type. The declaration of extern "C" is not supported in C language. There will be compiler syntax error when the. C file contains extern "C". Therefore, the use of external "C" is all placed in CPP program related files or its header files.
+
+
+The following forms are summarized:
+
+(1)C + + calls C functions:
+
+```c++
+//xx.h
+extern int add(...)
+
+//xx.c
+int add(){
+
+}
+
+//xx.cpp
+extern "C" {
+ #include "xx.h"
+}
+```
+
+(2)C calls C + + functions
+
+```c
+//xx.h
+extern "C"{
+ int add();
+}
+//xx.cpp
+int add(){
+
+}
+//xx.c
+extern int add();
+```
+
diff --git a/english/basic_content/extern/extern_c++/add.c b/english/basic_content/extern/extern_c++/add.c
new file mode 100644
index 0000000..b347468
--- /dev/null
+++ b/english/basic_content/extern/extern_c++/add.c
@@ -0,0 +1,5 @@
+#include "add.h"
+
+int add(int x,int y) {
+ return x+y;
+}
diff --git a/english/basic_content/extern/extern_c++/add.cpp b/english/basic_content/extern/extern_c++/add.cpp
new file mode 100644
index 0000000..8ed76fa
--- /dev/null
+++ b/english/basic_content/extern/extern_c++/add.cpp
@@ -0,0 +1,9 @@
+#include
+using namespace std;
+extern "C" {
+ #include "add.h"
+}
+int main() {
+ add(2,3);
+ return 0;
+}
diff --git a/english/basic_content/extern/extern_c++/add.h b/english/basic_content/extern/extern_c++/add.h
new file mode 100644
index 0000000..6984cdf
--- /dev/null
+++ b/english/basic_content/extern/extern_c++/add.h
@@ -0,0 +1,4 @@
+#ifndef ADD_H
+#define ADD_H
+extern int add(int x,int y);
+#endif
diff --git a/english/basic_content/extern/extern_c++/add.o b/english/basic_content/extern/extern_c++/add.o
new file mode 100644
index 0000000..4c8c016
Binary files /dev/null and b/english/basic_content/extern/extern_c++/add.o differ
diff --git a/english/basic_content/extern/extern_c++/main b/english/basic_content/extern/extern_c++/main
new file mode 100755
index 0000000..451dd01
Binary files /dev/null and b/english/basic_content/extern/extern_c++/main differ
diff --git a/english/basic_content/extern/extern_c/add.c b/english/basic_content/extern/extern_c/add.c
new file mode 100644
index 0000000..6f8a3d8
--- /dev/null
+++ b/english/basic_content/extern/extern_c/add.c
@@ -0,0 +1,5 @@
+extern int add(int x,int y);
+int main() {
+ add(2,3);
+ return 0;
+}
diff --git a/english/basic_content/extern/extern_c/add.cpp b/english/basic_content/extern/extern_c/add.cpp
new file mode 100644
index 0000000..b347468
--- /dev/null
+++ b/english/basic_content/extern/extern_c/add.cpp
@@ -0,0 +1,5 @@
+#include "add.h"
+
+int add(int x,int y) {
+ return x+y;
+}
diff --git a/english/basic_content/extern/extern_c/add.h b/english/basic_content/extern/extern_c/add.h
new file mode 100644
index 0000000..719b7c3
--- /dev/null
+++ b/english/basic_content/extern/extern_c/add.h
@@ -0,0 +1,6 @@
+#ifndef ADD_H
+#define ADD_H
+extern "C" {
+ int add(int x,int y);
+}
+#endif
diff --git a/english/basic_content/extern/extern_c/add.o b/english/basic_content/extern/extern_c/add.o
new file mode 100644
index 0000000..564710e
Binary files /dev/null and b/english/basic_content/extern/extern_c/add.o differ
diff --git a/english/basic_content/extern/extern_c/main b/english/basic_content/extern/extern_c/main
new file mode 100755
index 0000000..f026f11
Binary files /dev/null and b/english/basic_content/extern/extern_c/main differ
diff --git a/english/basic_content/friend/README.md b/english/basic_content/friend/README.md
new file mode 100644
index 0000000..01ebcbe
--- /dev/null
+++ b/english/basic_content/friend/README.md
@@ -0,0 +1,111 @@
+# Friend and Friend Class
+
+## About Author:
+
+
+
+
+## 0.Summary
+
+Friends provide a mechanism for ordinary functions or class member functions to access private or protected members in another class.In other words, there are two forms of friends:
+
+(1)Friend Function:Ordinary functions access a private or protected member of a class.
+
+(2)Friend Class:Member functions in class a access private or protected members in class B
+
+Advantages: improve the efficiency of the program.
+
+Disadvantages: it destroys the encapsulation of classes and the transparency of data.
+Conclusion:
+- Access to private members
+- Breaking encapsulation
+- Friendship is not transitive
+- The unidirectionality of friend relationship
+- There are no restrictions on the form and number of friend declarations
+
+## 1.Friend function
+
+It is declared in any region of the class declaration, and the definition is outside the class.
+
+```
+friend ();
+```
+
+Note that the friend function is only a common function, not a class member function of this class. It can be called anywhere. In the friend function, private or protected members of the class can be accessed through the object name.
+
+Code:[friend_func.cpp](friend_func.cpp)
+
+```c++
+#include
+
+using namespace std;
+
+class A
+{
+public:
+ A(int _a):a(_a){};
+ friend int geta(A &ca); ///< Friend function
+private:
+ int a;
+};
+
+int geta(A &ca)
+{
+ return ca.a;
+}
+
+int main()
+{
+ A a(3);
+ cout<;
+```
+
+Class B is a friend of class A, so class B can directly access private members of A.
+Code:[friend_class.cpp](friend_class.cpp)
+```c++
+#include
+
+using namespace std;
+
+class A
+{
+public:
+ A(int _a):a(_a){};
+ friend class B;
+private:
+ int a;
+};
+
+class B
+{
+public:
+ int getb(A ca) {
+ return ca.a;
+ };
+};
+
+int main()
+{
+ A a(3);
+ B b;
+ cout<
+
+using namespace std;
+
+class A
+{
+public:
+ A(int _a):a(_a){};
+ friend class B;
+private:
+ int a;
+};
+
+class B
+{
+public:
+ int getb(A ca) {
+ return ca.a;
+ };
+};
+
+int main()
+{
+ A a(3);
+ B b;
+ cout<
+
+using namespace std;
+
+class A
+{
+public:
+ A(int _a):a(_a){};
+ friend int geta(A &ca); ///< 友元函数
+private:
+ int a;
+};
+
+int geta(A &ca)
+{
+ return ca.a;
+}
+
+int main()
+{
+ A a(3);
+ cout<
+using namespace std;
+
+/**
+ * @brief 定义了一个变量pFun,这个变量是个指针,指向返回值和参数都是空的函数的指针!
+ */
+void (*pFun)(int);
+
+/**
+ * @brief 代表一种新类型,不是变量!所以与上述的pFun不一样!
+ */
+typedef void (*func)(void);
+
+void myfunc(void)
+{
+ cout<<"asda"<
+#include "inline.h"
+
+using namespace std;
+
+/**
+ * @brief To work, inline should be placed with function definition. Inline is a kind of "keyword for implementation, not for declaration"
+ *
+ * @param x
+ * @param y
+ *
+ * @return
+ */
+int Foo(int x,int y); // Function declaration
+
+
+inline int Foo(int x,int y) // Function definition
+{
+ return x+y;
+}
+
+// It is recommended to add the keyword "inline" to the definition!
+inline void A::f1(int x){
+
+}
+
+int main()
+{
+
+
+ cout<
+using namespace std;
+class Base
+{
+public:
+ inline virtual void who()
+ {
+ cout << "I am Base\n";
+ }
+ virtual ~Base() {}
+};
+class Derived : public Base
+{
+public:
+ inline void who() //
+ {
+ cout << "I am Derived\n";
+ }
+};
+
+int main()
+{
+ //
+ Base b;
+ b.who();
+
+ //
+ Base *ptr = new Derived();
+ ptr->who();
+
+ //
+ delete ptr;
+ ptr = nullptr;
+
+ system("pause");
+ return 0;
+}
+```
+
+
+
diff --git a/english/basic_content/inline/inline b/english/basic_content/inline/inline
new file mode 100755
index 0000000..c45bdb6
Binary files /dev/null and b/english/basic_content/inline/inline differ
diff --git a/english/basic_content/inline/inline.cpp b/english/basic_content/inline/inline.cpp
new file mode 100644
index 0000000..5b1463b
--- /dev/null
+++ b/english/basic_content/inline/inline.cpp
@@ -0,0 +1,57 @@
+#include
+#include "inline.h"
+
+
+
+using namespace std;
+
+/**
+ * @brief inline要起作用,inline要与函数定义放在一起,inline是一种“用于实现的关键字,而不是用于声明的关键字”
+ *
+ * @param x
+ * @param y
+ *
+ * @return
+ */
+int Foo(int x,int y); // 函数声明
+inline int Foo(int x,int y) // 函数定义
+{
+ return x+y;
+}
+
+
+
+// 定义处加inline关键字,推荐这种写法!
+inline void A::f1(int x){
+
+
+}
+
+
+
+/**
+ * @brief 内联能提高函数效率,但并不是所有的函数都定义成内联函数!内联是以代码膨胀(复制)为代价,仅仅省去了函数调用的开销,从而提高函数的执行效率。
+ * 如果执行函数体内代码的时间相比于函数调用的开销较大,那么效率的收货会更少!另一方面,每一处内联函数的调用都要复制代码,将使程序的总代码量增大,消耗更多的内存空间。
+ * 以下情况不宜用内联:
+ * (1) 如果函数体内的代码比较长,使得内联将导致内存消耗代价比较高。
+ * (2) 如果函数体内出现循环,那么执行函数体内代码的时间要比函数调用的开销大。
+ *
+ * @return
+ */
+int main()
+{
+
+
+ cout<
+using namespace std;
+class Base
+{
+ public:
+ inline virtual void who()
+ {
+ cout << "I am Base\n";
+ }
+ virtual ~Base() {}
+};
+class Derived : public Base
+{
+ public:
+ inline void who() // 不写inline时隐式内联
+ {
+ cout << "I am Derived\n";
+ }
+};
+
+int main()
+{
+ // 此处的虚函数 who(),是通过类(Base)的具体对象(b)来调用的,编译期间就能确定了,所以它可以是内联的,但最终是否内联取决于编译器。
+ Base b;
+ b.who();
+
+ // 此处的虚函数是通过指针调用的,呈现多态性,需要在运行时期间才能确定,所以不能为内联。
+ Base *ptr = new Derived();
+ ptr->who();
+
+ // 因为Base有虚析构函数(virtual ~Base() {}),所以 delete 时,会先调用派生类(Derived)析构函数,再调用基类(Base)析构函数,防止内存泄漏。
+ delete ptr;
+
+ return 0;
+}
diff --git a/english/basic_content/inline/iv b/english/basic_content/inline/iv
new file mode 100755
index 0000000..e0b0e95
Binary files /dev/null and b/english/basic_content/inline/iv differ
diff --git a/english/basic_content/macro/README.md b/english/basic_content/macro/README.md
new file mode 100644
index 0000000..18022cf
--- /dev/null
+++ b/english/basic_content/macro/README.md
@@ -0,0 +1,236 @@
+# Story about Macro
+
+
+
+
+
+## 1.The macro contains special symbols
+
+Several type:`#`,`##`,`\`
+
+### 1.1 String operator(#)
+
+**Using a # before macro parameter,The preprocessor converts this parameter into an array of characters**,In other words:**# is “stringlize”,The#, which appears in the macro definition, is to convert the following parameter into a string
+
+**。
+
+**Attention:It can only be used in macro definitions that have passed in parameters, and must be placed before the parameter name in the macro definition body.**
+
+For example:
+
+```c++
+#define exp(s) printf("test s is:%s\n",s)
+#define exp1(s) printf("test s is:%s\n",#s)
+#define exp2(s) #s
+int main() {
+ exp("hello");
+ exp1(hello);
+
+ string str = exp2( bac );
+ cout<(b) ? (a) \
+ :(b))
+int main() {
+ int max_val = MAX(3,6);
+ cout<0)
+ fun()
+```
+
+When this macro is expanded, it will be:
+
+```
+if(a>0)
+ f1();
+ f2();
+```
+
+
+In order to solve this problem, when writing code, usually can adopt
+
+`{}`。
+
+ex:
+
+```c++
+#define fun() {f1();f2();}
+if(a>0)
+ fun();
+// 宏展开
+if(a>0)
+{
+ f1();
+ f2();
+};
+```
+
+However, you will find that there is a semicolon after the macro is expanded, so the actual syntax is not correct.(Although the compiler runs well, there is no semicolon).
+
+### 2.2 Avoid using goto to control flow
+
+In some functions, we may need to do some cleaning before the return statement, such as releasing the memory space requested by malloc at the beginning of the function. Using goto is always a simple method:
+
+
+```c++
+int f() {
+ int *p = (int *)malloc(sizeof(int));
+ *p = 10;
+ cout<<*p<
+
diff --git a/english/basic_content/macro/do_while b/english/basic_content/macro/do_while
new file mode 100755
index 0000000..ce87035
Binary files /dev/null and b/english/basic_content/macro/do_while differ
diff --git a/english/basic_content/macro/do_while.cpp b/english/basic_content/macro/do_while.cpp
new file mode 100644
index 0000000..68af132
--- /dev/null
+++ b/english/basic_content/macro/do_while.cpp
@@ -0,0 +1,76 @@
+#include
+#include
+
+using namespace std;
+#define f1() cout<<"f1()"<0)
+ fun();
+
+ if(2>0)
+ fun1();
+
+ f();
+ ff();
+ fc();
+ return 0;
+}
diff --git a/english/basic_content/macro/sig_examp b/english/basic_content/macro/sig_examp
new file mode 100755
index 0000000..b342360
Binary files /dev/null and b/english/basic_content/macro/sig_examp differ
diff --git a/english/basic_content/macro/sig_examp.cpp b/english/basic_content/macro/sig_examp.cpp
new file mode 100644
index 0000000..85290a7
--- /dev/null
+++ b/english/basic_content/macro/sig_examp.cpp
@@ -0,0 +1,86 @@
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+///===========================================
+/**
+ * (#)字符串操作符
+ */
+///===========================================
+#define exp(s) printf("test s is:%s\n",s)
+#define exp1(s) printf("test s is:%s\n",#s)
+
+#define exp2(s) #s
+
+
+///===========================================
+/**
+ *(##)符号连接操作符
+ */
+///===========================================
+#define expA(s) printf("前缀加上后的字符串为:%s\n",gc_##s) //gc_s必须存在
+
+#define expB(s) printf("前缀加上后的字符串为:%s\n",gc_ ## s) //gc_s必须存在
+
+#define gc_hello1 "I am gc_hello1"
+
+
+///===========================================
+/**
+ * (\)续行操作符
+ */
+///===========================================
+#define MAX(a,b) ((a)>(b) ? (a) \
+ :(b))
+
+int main() {
+ ///===========================================
+ /**
+ * (#)字符串操作符
+ */
+ ///===========================================
+ exp("hello");
+ exp1(hello);
+
+ string str = exp2( bac );
+ cout<
+using namespace std;
+
+int count=0; // 全局(::)的count
+
+class A {
+public:
+ static int count; // 类A的count (A::count)
+
+};
+// 静态变量必须在此处定义
+int A::count;
+int main() {
+ ::count=1; // 设置全局的count为1
+ A::count=5; // 设置类A的count为2
+ cout< References must be initialized, and pointers can be uninitialized
+
+When we define a reference, we must specify an initial value for it, but the pointer does not
+
+```c++
+int &r; //Illegal, no initialization reference
+int *p; //It is legal, but p is a wild pointer. You should be careful when using it
+```
+
+> Reference cannot be null and pointer can be null
+
+Since the reference cannot be null, we do not need to test its validity when using a reference. When using a pointer, we need to first judge whether the pointer is a null pointer, otherwise it may cause the program to crash.
+```c++
+void test_p(int* p)
+{
+ if(p != null_ptr) //
+ *p = 3;
+ return;
+}
+void test_r(int& r)
+{
+ r = 3; //
+ return;
+}
+```
+
+> References cannot change targets
+
+
+
+The pointer can be changed at any time, but the reference can only point to the object pointed to during initialization, and cannot be changed.
+
+
+```
+int a = 1;
+int b = 2;
+
+int &r = a; //
+int *p = &a; //
+
+p = &b; //
+r = b; //引
+```
+
+## 2.Reference
+
+#### lvalue reference
+
+General reference, which generally represents the identity of an object.
+
+
+#### rvalue reference
+
+
+
+An R-value reference is a reference that must be bound to an R-value (a temporary object, an object to be destroyed), and generally represents the value of an object.
+
+
+An R-value reference is a reference that must be bound to an R-value (a temporary object, an object to be destroyed), and generally represents the value of an object.
+
+- It eliminates unnecessary copy of objects when two objects interact, saves operation storage resources and improves efficiency
+- It can define generic functions more concisely and clearly
+
+#### Reference collapse
+
+- `X& &`、`X& &&`、`X&& &` can be folded into `X&`
+- `X&& &&` can be floded into `X&&`
+
+The reference of C ++ **At the same time, it improves the security of memory operation and the beauty of semantics**。For example, the mandatory requirement of reference must be initialized, so that we don't have to judge whether the reference is empty when using the reference, which makes the code more concise and elegant, and avoids the situation of pointer flying all over the sky. In addition to this scenario, references are used for the following two scenarios:
+
+> Reference type parameter
+
+In general, we use const reference parameter as a read-only formal parameter. In this case, we can not only avoid parameter copy, but also get the same call method as value passing parameter.
+
+```c++
+void test(const vector &data)
+{
+ //...
+}
+int main()
+{
+ vector data{1,2,3,4,5,6,7,8};
+ test(data);
+}
+```
+
+> Reference type return value
+
+C++ Provides the ability to overload operators.The syntax of the overloaded operator is the same as that of the original operator.An example is the operator [] operator, which generally needs to return a reference object in order to be modified correctly.
+
+```c++
+vector v(10);
+v[5] = 10; //[]Operator returns the reference, and then the corresponding element of vector can be modified
+ //If[] operator do not return a reference but a pointer, the assignment statement needs to be written like this
+*v[5] = 10; // This way of writing is totally inconsistent with our understanding of the call of [], which is easy to be misunderstood
+```
+
+## 3.Performance gap between pointer and reference
+
+Is there a performance gap between pointers and references?This kind of problem needs to enter the assembly level to have a look. Let's first write a test1 function, which uses pointers for parameter passing:
+
+```c++
+void test1(int* p)
+{
+ *p = 3; //此处应该首先判断p是否为空,为了测试的需要,此处我们没加。
+ return;
+}
+```
+
+The assembly code corresponding to this code segment is as follows:
+
+```c++
+(gdb) disassemble
+Dump of assembler code for function test1(int*):
+ 0x0000000000400886 <+0>: push %rbp
+ 0x0000000000400887 <+1>: mov %rsp,%rbp
+ 0x000000000040088a <+4>: mov %rdi,-0x8(%rbp)
+=> 0x000000000040088e <+8>: mov -0x8(%rbp),%rax
+ 0x0000000000400892 <+12>: movl $0x3,(%rax)
+ 0x0000000000400898 <+18>: nop
+ 0x0000000000400899 <+19>: pop %rbp
+ 0x000000000040089a <+20>: retq
+End of assembler dump.
+
+```
+
+The above code lines 1 and 2 are the field operation of parameter calling and saving;The third line is parameter passing. The first parameter of the function call is usually placed in the RDI register. This line of code writes the RDI register value (the value of pointer P) to the stack;Line 4 writes the value of P in the stack to the rax register;Line 5 is to write the immediate number 3 to the**Memory pointed to by the value of the rax register**.
+
+Let's write out the reference C + + code segment test2 for parameter passing:
+
+```c++
+void test2(int& r)
+{
+ r = 3; // do not need to judge whether reference is null.
+ return;
+}
+```
+
+This code corresponds to the following assembly code:
+
+```c++
+(gdb) disassemble
+Dump of assembler code for function test2(int&):
+ 0x000000000040089b <+0>: push %rbp
+ 0x000000000040089c <+1>: mov %rsp,%rbp
+ 0x000000000040089f <+4>: mov %rdi,-0x8(%rbp)
+=> 0x00000000004008a3 <+8>: mov -0x8(%rbp),%rax
+ 0x00000000004008a7 <+12>: movl $0x3,(%rax)
+ 0x00000000004008ad <+18>: nop
+ 0x00000000004008ae <+19>: pop %rbp
+ 0x00000000004008af <+20>: retq
+End of assembler dump.
+
+```
+
+We find that the assembly code corresponding to test2 is exactly the same as that of test1.This shows that the C + + compiler compiles the pointer and reference into exactly the same machine code when compiling the program. Therefore, the reference in C + + is just a "syntax sugar" of pointer operation in C ++,In the underlying implementation, the C + + compiler implements these two operations in the same way.
+
+## 3. Conclusion
+
+The introduction of reference operation in C + + ensures the security and convenience of reference use and maintains the elegance of code under the condition of adding more restrictions on the use of reference. The use of reference can avoid the situation of "pointer flying all over the sky" to a certain extent, and it has a positive significance to improve the stability of the program. Finally, the underlying implementations of pointers and references are the same, and there is no need to worry about the performance gap between them.
+
+From:
diff --git a/english/basic_content/pointer_refer/copy_construct b/english/basic_content/pointer_refer/copy_construct
new file mode 100755
index 0000000..fa57fa3
Binary files /dev/null and b/english/basic_content/pointer_refer/copy_construct differ
diff --git a/english/basic_content/pointer_refer/copy_construct.cpp b/english/basic_content/pointer_refer/copy_construct.cpp
new file mode 100644
index 0000000..1fa28ba
--- /dev/null
+++ b/english/basic_content/pointer_refer/copy_construct.cpp
@@ -0,0 +1,35 @@
+/**
+ * @file copy_construct.cpp
+ * @brief g++ -o copy_construct copy_construct.cpp -fno-elide-constructors
+ * -fno-elide-constructors选项(关闭返回值优化)
+ * @author 光城
+ * @version v1
+ * @date 2019-08-09
+ */
+
+#include
+using namespace std;
+
+class Copyable {
+public:
+ Copyable(){}
+ Copyable(const Copyable &o) {
+ cout << "Copied" << endl;
+ }
+};
+Copyable ReturnRvalue() {
+ return Copyable(); //返回一个临时对象
+}
+void AcceptVal(Copyable a) {
+
+}
+void AcceptRef(const Copyable& a) {
+
+}
+
+int main() {
+ cout << "pass by value: " << endl;
+ AcceptVal(ReturnRvalue()); // 应该调用两次拷贝构造函数
+ cout << "pass by reference: " << endl;
+ AcceptRef(ReturnRvalue()); //应该只调用一次拷贝构造函数
+}
diff --git a/english/basic_content/pointer_refer/effec b/english/basic_content/pointer_refer/effec
new file mode 100755
index 0000000..a7bf86a
Binary files /dev/null and b/english/basic_content/pointer_refer/effec differ
diff --git a/english/basic_content/pointer_refer/effec.cpp b/english/basic_content/pointer_refer/effec.cpp
new file mode 100644
index 0000000..677353a
--- /dev/null
+++ b/english/basic_content/pointer_refer/effec.cpp
@@ -0,0 +1,22 @@
+#include
+using namespace std;
+void test1(int* p)
+{
+ *p = 3; //此处应该首先判断p是否为空,为了测试的需要,此处我们没加。
+ return;
+}
+
+void test2(int& p)
+{
+ p = 3; //此处应该首先判断p是否为空,为了测试的需要,此处我们没加。
+ return;
+}
+
+int main() {
+ int a=10;
+ int *p=&a;
+ test1(p);
+ test2(a);
+ cout<
+using namespace std;
+class A{};
+int main()
+{
+ cout<
+using namespace std;
+class A
+{
+ public:
+ char b;
+ virtual void fun() {};
+ static int c;
+ static int d;
+ static int f;
+};
+
+int main()
+{
+ /**
+ * @brief 16
+ */
+ cout<
+using namespace std;
+class A{
+ virtual void fun();
+ virtual void fun1();
+ virtual void fun2();
+ virtual void fun3();
+};
+int main()
+{
+ cout<
+
+using namespace std;
+
+class A
+{
+ public:
+ char a;
+ int b;
+};
+
+/**
+ * @brief
+ * char a
+ * int b
+ * short a
+ * long b
+ * 根据字节对齐4+4=8+8+8=24
+ */
+class B:A
+{
+ public:
+ short a;
+ long b;
+};
+class C
+{
+ A a;
+ char c;
+};
+class A1
+{
+ virtual void fun(){}
+};
+class C1:public A1
+{
+};
+
+int main()
+{
+ cout<
+using namespace std;
+class A
+{
+ virtual void fun() {}
+};
+class B
+{
+ virtual void fun2() {}
+};
+class C : virtual public A, virtual public B
+{
+ public:
+ virtual void fun3() {}
+};
+
+int main()
+{
+ /**
+ * @brief 8 8 16 The derived class inherits multiple virtual functions and inherits the VPTR of all virtual functions
+ */
+ cout<
+
+using namespace std;
+
+class A{};
+int main()
+{
+ cout<
+
+
+using namespace std;
+
+class A
+{
+ public:
+ A();
+ ~A();
+ static int a;
+ static void fun3();
+ void fun();
+ void fun1();
+};
+
+int main()
+{
+ cout<
+
+using namespace std;
+
+class A
+{
+ public:
+ char a;
+ int b;
+};
+
+/**
+ * @brief 此时B按照顺序:
+ * char a
+ * int b
+ * short a
+ * long b
+ * 根据字节对齐4+4=8+8+8=24
+ */
+class B:A
+{
+ public:
+ short a;
+ long b;
+};
+class C
+{
+ A a;
+ char c;
+};
+
+class A1
+{
+ virtual void fun(){}
+};
+class C1:public A
+{
+};
+
+
+int main()
+{
+ cout<
+
+using namespace std;
+
+class A
+{
+ public:
+ char a;
+ int b;
+};
+
+class B
+{
+ public:
+ short a;
+ long b;
+};
+
+/**
+ * @brief 8+16+8=32
+ */
+class C:A,B
+{
+ char c;
+};
+
+
+int main()
+{
+ cout<
+
+using namespace std;
+
+class A{
+
+ virtual void fun();
+ virtual void fun1();
+ virtual void fun2();
+ virtual void fun3();
+};
+int main()
+{
+ cout<
+using namespace std;
+class A
+{
+ public:
+ char b;
+ virtual void fun() {};
+ static int c;
+ static int d;
+ static int f;
+};
+
+
+
+int main()
+{
+
+ /**
+ * @brief 16 字节对齐、静态变量不影响类的大小、vptr指针=8
+ */
+ cout<
+
+using namespace std;
+
+class A
+{
+ virtual void fun() {}
+};
+
+class B
+{
+ virtual void fun2() {}
+};
+class C : virtual public A, virtual public B
+{
+ public:
+ virtual void fun3() {}
+};
+
+
+int main()
+{
+
+ /**
+ * @brief 8 8 16 派生类虚继承多个虚函数,会继承所有虚函数的vptr
+ */
+ cout<
+
+using namespace std;
+
+class A
+{
+ virtual void fun() {}
+};
+
+class B
+{
+ virtual void fun2() {}
+};
+class C : public A, public B
+{
+ public:
+ virtual void fun3() {}
+};
+
+
+int main()
+{
+
+ /**
+ * @brief 8 8 16 派生类继承多个虚函数,会继承所有虚函数的vptr
+ */
+ cout<
+#include
+using namespace std;
+
+void demo()
+{
+ // static variable
+ static int count = 0;
+ cout << count << " ";
+
+ // value is updated and
+ // will be carried to next
+ // function calls
+ count++;
+}
+
+int main()
+{
+ for (int i=0; i<5; i++)
+ demo();
+ return 0;
+}
+```
+
+Output:
+
+```
+0 1 2 3 4
+```
+
+You can see in the above program that the variable count is declared static.So, Its value is passed through a function call. The variable count is not initialized each time the function is called.
+
+- Static variables in class
+
+Because variables declared static are initialized only once,Because they allocate space in separate static storage。Therefore, static variables in a class are **shared by objects。**You cannot have multiple copies of the same static variable for different objects. For this reason, static variables cannot be initialized with constructors.
+
+```c++
+
+#include
+using namespace std;
+
+class Apple
+{
+public:
+ static int i;
+
+ Apple()
+ {
+ // Do nothing
+ };
+};
+
+int main()
+{
+Apple obj1;
+Apple obj2;
+obj1.i =2;
+obj2.i = 3;
+
+// prints value of i
+cout << obj1.i<<" "<
+using namespace std;
+
+class Apple
+{
+public:
+ static int i;
+
+ Apple()
+ {
+ // Do nothing
+ };
+};
+
+int Apple::i = 1;
+
+int main()
+{
+ Apple obj;
+ // prints value of i
+ cout << obj.i;
+}
+```
+
+Output:
+
+```
+1
+```
+
+**Static member**
+
+- Class objects are static
+
+Just like variables, objects have scope when declared static until the life cycle of the program
+
+Consider the following program, where the object is non static
+
+```c++
+#include
+using namespace std;
+
+class Apple
+{
+ int i;
+ public:
+ Apple()
+ {
+ i = 0;
+ cout << "Inside Constructor\n";
+ }
+ ~Apple()
+ {
+ cout << "Inside Destructor\n";
+ }
+};
+
+int main()
+{
+ int x = 0;
+ if (x==0)
+ {
+ Apple obj;
+ }
+ cout << "End of main\n";
+}
+
+```
+
+
+Output:
+
+```c++
+Inside Constructor
+Inside Destructor
+End of main
+```
+
+In the above program, the object is declared non static within the if block. Therefore, the scope of the variable is only within the if block. Therefore, when an object is created, the constructor is called, and is called when the control of the if block passes over the destructor, because the scope of the object is only within the if block in which it is declared.
+
+If we declare the object static, now let's look at the changes in the output.
+
+```c++
+#include
+using namespace std;
+
+class Apple
+{
+ int i;
+ public:
+ Apple()
+ {
+ i = 0;
+ cout << "Inside Constructor\n";
+ }
+ ~Apple()
+ {
+ cout << "Inside Destructor\n";
+ }
+};
+
+int main()
+{
+ int x = 0;
+ if (x==0)
+ {
+ static Apple obj;
+ }
+ cout << "End of main\n";
+}
+
+```
+
+
+Output:
+
+```
+Inside Constructor
+End of main
+Inside Destructor
+```
+
+You can clearly see the output change. Now, call the destructor function after the end of main.This is because the scope of static objects is throughout the life cycle of the program.
+
+- Static functions in class
+
+Just like static data members or static variables in a class, Static member functions are also independent of class objects.We are allowed to use objects and "." to call static member functions. However, it is recommended to call static members using class names and range resolution operators.
+
+Allows static member functions to access only static data members or other static member functions that cannot access non static data members or member functions of a class.
+
+```c++
+#include
+using namespace std;
+
+class Apple
+{
+ public:
+ // static member function
+ static void printMsg()
+ {
+ cout<<"Welcome to Apple!";
+ }
+};
+
+// main function
+int main()
+{
+ // invoking a static member function
+ Apple::printMsg();
+}
+```
+
+Output:
+
+```
+Welcome to Apple!
+```
+
diff --git a/english/basic_content/static/demo b/english/basic_content/static/demo
new file mode 100755
index 0000000..fdd7a26
Binary files /dev/null and b/english/basic_content/static/demo differ
diff --git a/english/basic_content/static/nostatic_class.cpp b/english/basic_content/static/nostatic_class.cpp
new file mode 100644
index 0000000..b4e56d2
--- /dev/null
+++ b/english/basic_content/static/nostatic_class.cpp
@@ -0,0 +1,28 @@
+#include
+using namespace std;
+
+class Apple
+{
+ int i;
+ public:
+ Apple()
+ {
+ i = 0;
+ cout << "Inside Constructor\n";
+ }
+ ~Apple()
+ {
+ cout << "Inside Destructor\n";
+ }
+};
+
+int main()
+{
+ int x = 0;
+ if (x==0)
+ {
+ Apple obj;
+ }
+ cout << "End of main\n";
+}
+
diff --git a/english/basic_content/static/static_class.cpp b/english/basic_content/static/static_class.cpp
new file mode 100644
index 0000000..007e400
--- /dev/null
+++ b/english/basic_content/static/static_class.cpp
@@ -0,0 +1,28 @@
+#include
+using namespace std;
+
+class Apple
+{
+ int i;
+ public:
+ Apple()
+ {
+ i = 0;
+ cout << "Inside Constructor\n";
+ }
+ ~Apple()
+ {
+ cout << "Inside Destructor\n";
+ }
+};
+
+int main()
+{
+ int x = 0;
+ if (x==0)
+ {
+ static Apple obj;
+ }
+ cout << "End of main\n";
+}
+
diff --git a/english/basic_content/static/static_demo.cpp b/english/basic_content/static/static_demo.cpp
new file mode 100644
index 0000000..1910088
--- /dev/null
+++ b/english/basic_content/static/static_demo.cpp
@@ -0,0 +1,24 @@
+// the use of static Static
+// variables in a Function
+#include
+#include
+using namespace std;
+
+void demo()
+{
+ // static variable
+ static int count = 0;
+ cout << count << " ";
+
+ // value is updated and
+ // will be carried to next
+ // function calls
+ count++;
+}
+
+int main()
+{
+ for (int i=0; i<5; i++)
+ demo();
+ return 0;
+}
diff --git a/english/basic_content/static/static_error_variable.cpp b/english/basic_content/static/static_error_variable.cpp
new file mode 100644
index 0000000..47b1319
--- /dev/null
+++ b/english/basic_content/static/static_error_variable.cpp
@@ -0,0 +1,26 @@
+// variables inside a class
+
+#include
+using namespace std;
+
+class Apple
+{
+ public:
+ static int i;
+
+ Apple()
+ {
+ // Do nothing
+ };
+};
+
+int main()
+{
+ Apple obj1;
+ Apple obj2;
+ obj1.i =2;
+ obj2.i = 3;
+
+ // prints value of i
+ cout << obj1.i<<" "<
+using namespace std;
+
+class Apple
+{
+ public:
+ // static member function
+ static void printMsg()
+ {
+ cout<<"Welcome to Apple!";
+ }
+};
+
+// main function
+int main()
+{
+ // invoking a static member function
+ Apple::printMsg();
+}
+
diff --git a/english/basic_content/static/static_variable.cpp b/english/basic_content/static/static_variable.cpp
new file mode 100644
index 0000000..b14780e
--- /dev/null
+++ b/english/basic_content/static/static_variable.cpp
@@ -0,0 +1,24 @@
+// variables inside a class
+
+#include
+using namespace std;
+
+class GfG
+{
+ public:
+ static int i;
+
+ GfG()
+ {
+ // Do nothing
+ };
+};
+
+int GfG::i = 1;
+
+int main()
+{
+ GfG obj;
+ // prints value of i
+ cout << obj.i;
+}
diff --git a/english/basic_content/struct/README.md b/english/basic_content/struct/README.md
new file mode 100644
index 0000000..200c698
--- /dev/null
+++ b/english/basic_content/struct/README.md
@@ -0,0 +1,226 @@
+# Understand C and C + + struct
+
+
+
+
+
+## 1.Struct In C
+
+- In C, struct is only used as the composite type of data, that is, in the structure declaration, only data members can be placed inside, but not functions
+- C + + access modifiers cannot be used in C structure declarations,such as:public、protected、private. But they can be used in C + +
+- Define the structure variable in C. If you use the following definition, you must add struct
+- The structure of C cannot be inherited (there is no such concept)
+- If the structure name is the same as the function name, it can run normally and call normally! For example, you can define void base() that does not conflict with struct base{}。
+
+Example:
+
+```c
+#include
+
+struct Base { // public
+ int v1;
+// public: //error
+ int v2;
+ //private:
+ int v3;
+ //void print(){ // c中不能在结构体中嵌入函数
+ // printf("%s\n","hello world");
+ //}; //error!
+};
+
+void Base(){
+ printf("%s\n","I am Base func");
+}
+//struct Base base1; //ok
+//Base base2; //error
+int main() {
+ struct Base base;
+ base.v1=1;
+ //base.print();
+ printf("%d\n",base.v1);
+ Base();
+ return 0;
+}
+```
+
+Finally Output:
+
+```
+1
+I am Base func
+```
+
+Code:[struct_func.c](./struct_func.c)
+
+## 2.C++ struct
+
+The comparison with C is as follows:
+
+- In C + + structure, not only data can be defined, but also functions can be defined.
+- Access modifiers can be used in C + + structures, such as :public、protected、private 。
+- C + + structure can be used directly without struct.
+- C + + inheritance
+- If the structure name is the same as the function name, it can run normally and call normally!However, when defining the structure variable, we only use the structure with struct!
+
+Example:
+
+> Case 1:
+
+Before adding a function with the same name:
+
+```c++
+struct Student {
+
+};
+Student(){}
+Struct Student s; //ok
+Student s; //ok
+```
+
+After adding a function with the same name:
+
+```c++
+struct Student {
+
+};
+Student(){}
+Struct Student s; //ok
+Student s; //error
+```
+
+> Case 2:
+
+```c++
+typedef struct Base1 {
+ int v1;
+// private: //error!
+ int v3;
+ public: //显示声明public
+ int v2;
+ void print(){
+ printf("%s\n","hello world");
+ };
+}B;
+//void B() {} //error! 符号 "B" 已经被定义为一个 "struct Base1" 的别名
+```
+
+> The first three cases
+
+```c++
+#include
+#include
+
+struct Base {
+ int v1;
+// private: //error!
+ int v3;
+ public: //显示声明public
+ int v2;
+ void print(){
+ printf("%s\n","hello world");
+ };
+};
+
+int main() {
+ struct Base base1; //ok
+ Base base2; //ok
+ Base base;
+ base.v1=1;
+ base.v3=2;
+ base.print();
+ printf("%d\n",base.v1);
+ printf("%d\n",base.v3);
+ return 0;
+}
+```
+
+Code :[struct_func.cpp](struct_func.cpp)
+
+> Inheritance cases
+
+```c++
+#include
+#include
+struct Base {
+ int v1;
+// private: //error!
+ int v3;
+ public: //显示声明public
+ int v2;
+ virtual void print(){
+ printf("%s\n","Base");
+ };
+};
+struct Derived:Base {
+
+ public:
+ int v2;
+ void print(){
+ printf("%s\n","Derived");
+ };
+};
+int main() {
+ Base *b=new Derived();
+ b->print();
+ return 0;
+}
+```
+
+Code:[ext_struct_func.cpp](./ext_struct_func.cpp)
+
+> Functions with the same name
+
+```c++
+#include
+#include
+
+struct Base {
+ int v1;
+// private: //error!
+ int v3;
+ public: //显示声明public
+ int v2;
+ void print(){
+ printf("%s\n","hello world");
+ };
+};
+
+typedef struct Base1 {
+ int v1;
+// private: //error!
+ int v3;
+ public: //显示声明public
+ int v2;
+ void print(){
+ printf("%s\n","hello world");
+ };
+}B;
+void Base(){
+ printf("%s\n","I am Base func");
+}
+//void B() {} //error! 符号 "B" 已经被定义为一个 "struct Base1" 的别名
+int main() {
+ struct Base base; //ok
+ //Base base1; // error!
+ base.v1=1;
+ base.v3=2;
+ base.print();
+ printf("%d\n",base.v1);
+ printf("%d\n",base.v3);
+ Base();
+ return 0;
+}
+```
+Code:[struct_func_func.cpp](./struct_func_func.cpp)
+
+## 3.Conclusion
+
+### The difference of structure between C and C + +
+
+| C | C++ |
+| ------------------------------------------------------ | ------------------------------------------------------------ |
+| You cannot place a function in a structure declaration | Function can be declared in structure |
+| C + + access modifiers cannot be used in C structure declarations. | public、protected、private They can be used in C + + |
+| Define the structure variable in C. If you use the following definition, you must add struct | You can do without struct |
+|Not inheritance | you could use inheritance |
+| If the structure name is the same as the function name, it can run normally and call normally | If the structure name is the same as the function name, the structure can only be defined with struct |
diff --git a/english/basic_content/struct/ext b/english/basic_content/struct/ext
new file mode 100755
index 0000000..45104f8
Binary files /dev/null and b/english/basic_content/struct/ext differ
diff --git a/english/basic_content/struct/ext_struct_func.cpp b/english/basic_content/struct/ext_struct_func.cpp
new file mode 100644
index 0000000..7ab1eb2
--- /dev/null
+++ b/english/basic_content/struct/ext_struct_func.cpp
@@ -0,0 +1,33 @@
+#include
+#include
+using namespace std;
+struct Base {
+ int v1;
+// private: //error!
+ int v3;
+ public: //显示声明public
+ int v2;
+ virtual void print(){
+ printf("%s\n","Base");
+ };
+ Base(){cout<<"Base construct"<print();
+ delete b;
+ return 0;
+}
diff --git a/english/basic_content/struct/sf b/english/basic_content/struct/sf
new file mode 100755
index 0000000..321061d
Binary files /dev/null and b/english/basic_content/struct/sf differ
diff --git a/english/basic_content/struct/stff b/english/basic_content/struct/stff
new file mode 100755
index 0000000..de43727
Binary files /dev/null and b/english/basic_content/struct/stff differ
diff --git a/english/basic_content/struct/struct_func b/english/basic_content/struct/struct_func
new file mode 100755
index 0000000..8541eba
Binary files /dev/null and b/english/basic_content/struct/struct_func differ
diff --git a/english/basic_content/struct/struct_func.c b/english/basic_content/struct/struct_func.c
new file mode 100644
index 0000000..6bea643
--- /dev/null
+++ b/english/basic_content/struct/struct_func.c
@@ -0,0 +1,27 @@
+#include
+
+struct Base { // public
+ int v1;
+// public: //error
+ int v2;
+ //private:
+ int v3;
+ //void print(){ // c中不能在结构体中嵌入函数
+ // printf("%s\n","hello world");
+ //}; //error!
+};
+
+void Base(){
+ printf("%s\n","I am Base func");
+}
+//struct Base base1; //ok
+//Base base2; //error
+
+int main() {
+ struct Base base;
+ base.v1=1;
+ //base.print();
+ printf("%d\n",base.v1);
+ Base();
+ return 0;
+}
diff --git a/english/basic_content/struct/struct_func.cpp b/english/basic_content/struct/struct_func.cpp
new file mode 100644
index 0000000..09bef26
--- /dev/null
+++ b/english/basic_content/struct/struct_func.cpp
@@ -0,0 +1,25 @@
+#include
+#include
+
+struct Base {
+ int v1;
+// private: //error!
+ int v3;
+ public: //显示声明public
+ int v2;
+ void print(){
+ printf("%s\n","hello world");
+ };
+};
+
+int main() {
+ struct Base base1; //ok
+ Base base2; //ok
+ Base base;
+ base.v1=1;
+ base.v3=2;
+ base.print();
+ printf("%d\n",base.v1);
+ printf("%d\n",base.v3);
+ return 0;
+}
diff --git a/english/basic_content/struct/struct_func_func.cpp b/english/basic_content/struct/struct_func_func.cpp
new file mode 100644
index 0000000..bce3749
--- /dev/null
+++ b/english/basic_content/struct/struct_func_func.cpp
@@ -0,0 +1,39 @@
+#include
+#include
+
+struct Base {
+ int v1;
+// private: //error!
+ int v3;
+ public: //显示声明public
+ int v2;
+ void print(){
+ printf("%s\n","hello world");
+ };
+};
+
+typedef struct Base1 {
+ int v1;
+// private: //error!
+ int v3;
+ public: //显示声明public
+ int v2;
+ void print(){
+ printf("%s\n","hello world");
+ };
+}B;
+void Base(){
+ printf("%s\n","I am Base func");
+}
+//void B() {} //error! 符号 "B" 已经被定义为一个 "struct Base1" 的别名
+int main() {
+ struct Base base; //ok
+ //Base base1; // error!
+ base.v1=1;
+ base.v3=2;
+ base.print();
+ printf("%d\n",base.v1);
+ printf("%d\n",base.v3);
+ Base();
+ return 0;
+}
diff --git a/english/basic_content/struct/stu b/english/basic_content/struct/stu
new file mode 100755
index 0000000..6dabbe1
Binary files /dev/null and b/english/basic_content/struct/stu differ
diff --git a/english/basic_content/struct_class/README.md b/english/basic_content/struct_class/README.md
new file mode 100644
index 0000000..aeca0f5
--- /dev/null
+++ b/english/basic_content/struct_class/README.md
@@ -0,0 +1,19 @@
+# The difference struct and class
+
+
+
+
+
+More detail about struct [Story about struct](../struct)
+
+Generally speaking, struct is more suitable to be regarded as an implementation body of data structure, and class is more suitable to be regarded as the implementation body of an object.
+
+Dif:
+
+One of the essential differences is the default access control
+
+
+
+Default inherited access.Struct is public, while class is private.
+
+Structure as the implementation body of data structure.Its default data access control is public, while class is the implementation body of the object, and its default member variable access control is private.
diff --git a/english/basic_content/this/README.md b/english/basic_content/this/README.md
new file mode 100644
index 0000000..1ce99f3
--- /dev/null
+++ b/english/basic_content/this/README.md
@@ -0,0 +1,87 @@
+# Story about this
+
+## About Author
+
+
+
+
+## 1.This pointer
+
+I believe that many people sitting here are learning python. For Python, there is self. Analogy to C + + is this pointer. Let's analyze the use of this pointer in class.
+
+Let's first talk about the use of this pointer:
+
+(1)This pointer to an object is not part of the object itself and does not affect the result of sizeof.
+
+(2)This scope is within the class. When accessing the non static members of the class in the non static member function of the class, the compiler will automatically pass the address of the object itself to the function as an implicit parameter. That is to say, even if you don't write this pointer, the compiler will add this when compiling. As the implicit formal parameter of non static member function, the access to each member is carried out through this.
+
+Second, the use of this pointer:
+
+(1)When the class object itself is returned in a class's non static member function, directly use return *this。
+
+(2)When the parameter is the same as the member variable name, 如this->n = n (不能写成n = n)。
+
+
+The following examples are available:
+
+```c++
+#include
+#include
+
+
+using namespace std;
+class Person{
+public:
+ typedef enum {
+ BOY = 0,
+ GIRL
+ }SexType;
+ Person(char *n, int a,SexType s){
+ name=new char[strlen(n)+1];
+ strcpy(name,n);
+ age=a;
+ sex=s;
+ }
+ int get_age() const{
+
+ return this->age;
+ }
+ Person& add_age(int a){
+ age+=a;
+ return *this;
+ }
+ ~Person(){
+ delete [] name;
+ }
+private:
+ char * name;
+ int age;
+ SexType sex;
+};
+
+
+int main(){
+ Person p("zhangsan",20,Person::BOY);
+ cout<
+#include
+
+
+using namespace std;
+class Person{
+public:
+ typedef enum {
+ BOY = 0,
+ GIRL
+ }SexType;
+ Person(char *n, int a,SexType s){
+ name=new char[strlen(n)+1];
+ strcpy(name,n);
+ age=a;
+ sex=s;
+ }
+ int get_age() const{
+
+ return this->age;
+ }
+ Person& add_age(int a){
+ age+=a;
+ return *this;
+ }
+ ~Person(){
+ delete [] name;
+ }
+private:
+ char * name;
+ int age;
+ SexType sex;
+};
+
+
+int main(){
+ Person p("zhangsan",20,Person::BOY);
+ cout<
+/**
+ * 默认访问控制符为public
+ */
+union UnionTest {
+ /**
+ * 可以含有构造函数、析构函数
+ */
+ UnionTest() : i(10) {print(i);};
+ ~UnionTest(){};
+ int i;
+private:
+ void print(int i){std::cout<
+#define isNs1 1
+//#define isGlobal 2
+using namespace std;
+void func()
+{
+ cout<<"::func"<
+using namespace std;
+
+class Base{
+ public:
+ void f(){ cout<<"f()"< V1;
+using V2 = vector;
+```
+Code:[using_typedef.cpp](using_typedef.cpp)
diff --git a/english/basic_content/using/derived_base b/english/basic_content/using/derived_base
new file mode 100755
index 0000000..952568a
Binary files /dev/null and b/english/basic_content/using/derived_base differ
diff --git a/english/basic_content/using/derived_base.cpp b/english/basic_content/using/derived_base.cpp
new file mode 100644
index 0000000..bc57800
--- /dev/null
+++ b/english/basic_content/using/derived_base.cpp
@@ -0,0 +1,48 @@
+#include
+
+using namespace std;
+
+class Base1 {
+ public:
+ Base1():value(10) {}
+ virtual ~Base1() {}
+ void test1() { cout << "Base test1..." << endl; }
+ protected: // 保护
+ int value;
+};
+// 默认为私有继承
+class Derived1 : Base1 {
+ public:
+ void test2() { cout << "value is " << value << endl; }
+};
+
+class Base {
+ public:
+ Base():value(20) {}
+ virtual ~Base() {}
+ void test1() { cout << "Base test1..." << endl; }
+ private: //私有
+ int value;
+};
+
+/**
+ * 子类对父类成员的访问权限跟如何继承没有任何关系,
+ * “子类可以访问父类的public和protected成员,不可以访问父类的private成员”——这句话对任何一种继承都是成立的。
+ *
+ */
+class Derived : Base {
+ public:
+ using Base::value;
+ void test2() { cout << "value is " << value << endl; }
+};
+
+
+int main()
+{
+ Derived1 d1;
+ d1.test2();
+
+ Derived d;
+ d.test2();
+ return 0;
+}
diff --git a/english/basic_content/using/using_derived b/english/basic_content/using/using_derived
new file mode 100755
index 0000000..641ac8b
Binary files /dev/null and b/english/basic_content/using/using_derived differ
diff --git a/english/basic_content/using/using_derived.cpp b/english/basic_content/using/using_derived.cpp
new file mode 100644
index 0000000..eb7b5ae
--- /dev/null
+++ b/english/basic_content/using/using_derived.cpp
@@ -0,0 +1,36 @@
+/**
+ * @file using_derived.cpp
+ * @brief 函数重装
+ * @author 光城
+ * @version v1
+ * @date 2019-08-07
+ */
+
+#include
+using namespace std;
+
+class Base{
+ public:
+ void f(){ cout<<"f()"<
+#define isNs1 1
+//#define isGlobal 2
+using namespace std;
+void func()
+{
+ cout<<"::func"<
+#include
+using namespace std;
+
+typedef vector V1;
+using V2 = vector;
+
+
+int main()
+{
+ int nums1[] = {1,2,3,4,5,6};
+ V1 vec1(nums1,nums1+sizeof(nums1)/sizeof(int));
+ int nums2[] = {5,7,6};
+ V2 vec2(nums2,nums2+sizeof(nums2)/sizeof(int));
+
+ for(auto i:vec1)
+ cout<
+using namespace std;
+
+
+class Employee
+{
+ public:
+ virtual void raiseSalary()
+ {
+ cout<<0<raiseSalary(); // Polymorphic Call: Calls raiseSalary()
+ // according to the actual object, not
+ // according to the type of pointer
+}
+int main(){
+ Employee *emp[]={new Manager(),new Engineer};
+ globalRaiseSalary(emp,2);
+ return 0;
+}
diff --git a/english/basic_content/virtual/set2/default_arg.cpp b/english/basic_content/virtual/set2/default_arg.cpp
new file mode 100644
index 0000000..4797818
--- /dev/null
+++ b/english/basic_content/virtual/set2/default_arg.cpp
@@ -0,0 +1,39 @@
+/**
+ * @file first_example.cpp
+ * @brief 虚函数中默认参数
+ * 规则:虚函数是动态绑定的,默认参数是静态绑定的。默认参数的使用需要看指针或者应用本身的类型,而不是对象的类型!
+ * @author 光城
+ * @version v1
+ * @date 2019-07-24
+ */
+
+#include
+using namespace std;
+
+class Base
+{
+ public:
+ virtual void fun ( int x = 10 )
+ {
+ cout << "Base::fun(), x = " << x << endl;
+ }
+};
+
+class Derived : public Base
+{
+ public:
+ virtual void fun ( int x=20 )
+ {
+ cout << "Derived::fun(), x = " << x << endl;
+ }
+};
+
+
+int main()
+{
+ Derived d1;
+ Base *bp = &d1;
+ bp->fun(); // 10
+ return 0;
+}
+
diff --git a/english/basic_content/virtual/set3/copy_consrtuct.cpp b/english/basic_content/virtual/set3/copy_consrtuct.cpp
new file mode 100644
index 0000000..e65ca89
--- /dev/null
+++ b/english/basic_content/virtual/set3/copy_consrtuct.cpp
@@ -0,0 +1,41 @@
+#include
+using namespace std;
+
+class Base
+{
+ public:
+
+};
+
+class Derived : public Base
+{
+ public:
+ Derived()
+ {
+ cout << "Derived created" << endl;
+ }
+
+ Derived(const Derived &rhs)
+ {
+ cout << "Derived created by deep copy" << endl;
+ }
+
+ ~Derived()
+ {
+ cout << "Derived destroyed" << endl;
+ }
+};
+
+int main()
+{
+ Derived s1;
+
+ Derived s2 = s1; // Compiler invokes "copy constructor"
+ // Type of s1 and s2 are concrete to compiler
+
+ // How can we create Derived1 or Derived2 object
+ // from pointer (reference) to Base class pointing Derived object?
+
+ return 0;
+}
+
diff --git a/english/basic_content/virtual/set3/full_virde.cpp b/english/basic_content/virtual/set3/full_virde.cpp
new file mode 100644
index 0000000..d4ef7a8
--- /dev/null
+++ b/english/basic_content/virtual/set3/full_virde.cpp
@@ -0,0 +1,39 @@
+/**
+ * @file full_virde.cpp
+ * @brief 将基类的析构函数声明为虚函数
+ * 输出结果:
+ * Constructing base
+ * Constructing derived
+ * Destructing derived
+ * Destructing base
+ * @author 光城
+ * @version v1
+ * @date 2019-07-24
+ */
+#include
+
+using namespace std;
+
+class base {
+ public:
+ base()
+ { cout<<"Constructing base \n"; }
+ virtual ~base()
+ { cout<<"Destructing base \n"; }
+};
+
+class derived: public base {
+ public:
+ derived()
+ { cout<<"Constructing derived \n"; }
+ ~derived()
+ { cout<<"Destructing derived \n"; }
+};
+
+int main(void)
+{
+ derived *d = new derived();
+ base *b = d;
+ delete b;
+ return 0;
+}
diff --git a/english/basic_content/virtual/set3/inline_virtual.cpp b/english/basic_content/virtual/set3/inline_virtual.cpp
new file mode 100644
index 0000000..1ec1a06
--- /dev/null
+++ b/english/basic_content/virtual/set3/inline_virtual.cpp
@@ -0,0 +1,35 @@
+#include
+using namespace std;
+class Base
+{
+ public:
+ inline virtual void who()
+ {
+ cout << "I am Base\n";
+ }
+ virtual ~Base() {}
+};
+class Derived : public Base
+{
+ public:
+ inline void who() // 不写inline时隐式内联
+ {
+ cout << "I am Derived\n";
+ }
+};
+
+int main()
+{
+ // 此处的虚函数 who(),是通过类(Base)的具体对象(b)来调用的,编译期间就能确定了,所以它可以是内联的,但最终是否内联取决于编译器。
+ Base b;
+ b.who();
+
+ // 此处的虚函数是通过指针调用的,呈现多态性,需要在运行时期间才能确定,所以不能为内联。
+ Base *ptr = new Derived();
+ ptr->who();
+
+ // 因为Base有虚析构函数(virtual ~Base() {}),所以 delete 时,会先调用派生类(Derived)析构函数,再调用基类(Base)析构函数,防止内存泄漏。
+ delete ptr;
+
+ return 0;
+}
diff --git a/english/basic_content/virtual/set3/static_error.cpp b/english/basic_content/virtual/set3/static_error.cpp
new file mode 100644
index 0000000..5a79667
--- /dev/null
+++ b/english/basic_content/virtual/set3/static_error.cpp
@@ -0,0 +1,13 @@
+/**
+ * @file static_error.cpp
+ * @brief 静态函数不可以声明为虚函数,同时也不能被const和volatile关键字修饰!
+ * 原因如下:
+ * static成员函数不属于任何类对象或类实例,所以即使给此函数加上virutal也是没有任何意义
+ * 虚函数依靠vptr和vtable来处理。vptr是一个指针,在类的构造函数中创建生成,并且只能用this指针来访问它,静态成员函数没有this指针,所以无法访问vptr。
+ * @author 光城
+ * @version v1
+ * @date 2019-07-24
+ */
+
+virtual static void fun() { }
+static void fun() const { }
diff --git a/english/basic_content/virtual/set3/vir_con.cpp b/english/basic_content/virtual/set3/vir_con.cpp
new file mode 100644
index 0000000..78c4a07
--- /dev/null
+++ b/english/basic_content/virtual/set3/vir_con.cpp
@@ -0,0 +1,206 @@
+/**
+ * @file vir_con.cpp
+ * @brief 构造函数不可以声明为虚函数。同时除了inline之外,构造函数不允许使用其它任何关键字。
+ *
+ * 为什么构造函数不可以为虚函数?
+ *
+ * 尽管虚函数表vtable是在编译阶段就已经建立的,但指向虚函数表的指针vptr是在运行阶段实例化对象时才产生的。 如果类含有虚函数,编译器会在构造函数中添加代码来创建vptr。 问题来了,如果构造函数是虚的,那么它需要vptr来访问vtable,可这个时候vptr还没产生。 因此,构造函数不可以为虚函数。
+ * 我们之所以使用虚函数,是因为需要在信息不全的情况下进行多态运行。而构造函数是用来初始化实例的,实例的类型必须是明确的。
+ * 因此,构造函数没有必要被声明为虚函数。
+ * 尽管构造函数不可以为虚函数,但是有些场景下我们确实需要 “Virtual Copy Constructor”。 “虚复制构造函数”的说法并不严谨,其只是一个实现了对象复制的功能的类内函数。 举一个应用场景,比如剪切板功能。 复制内容作为基类,但派生类可能包含文字、图片、视频等等。 我们只有在程序运行的时候才知道我们需要复制的具体是什么类型的数据。
+ *
+ * @author 光城
+ * @version v1
+ * @date 2019-07-24
+ */
+
+#include
+using namespace std;
+
+//// LIBRARY SRART
+class Base
+{
+ public:
+ Base() { }
+
+ virtual // Ensures to invoke actual object destructor
+ ~Base() { }
+
+ virtual void ChangeAttributes() = 0;
+
+ // The "Virtual Constructor"
+ static Base *Create(int id);
+
+ // The "Virtual Copy Constructor"
+ virtual Base *Clone() = 0;
+};
+
+class Derived1 : public Base
+{
+ public:
+ Derived1()
+ {
+ cout << "Derived1 created" << endl;
+ }
+
+ Derived1(const Derived1& rhs)
+ {
+ cout << "Derived1 created by deep copy" << endl;
+ }
+
+ ~Derived1()
+ {
+ cout << "~Derived1 destroyed" << endl;
+ }
+
+ void ChangeAttributes()
+ {
+ cout << "Derived1 Attributes Changed" << endl;
+ }
+
+ Base *Clone()
+ {
+ return new Derived1(*this);
+ }
+};
+
+class Derived2 : public Base
+{
+ public:
+ Derived2()
+ {
+ cout << "Derived2 created" << endl;
+ }
+
+ Derived2(const Derived2& rhs)
+ {
+ cout << "Derived2 created by deep copy" << endl;
+ }
+
+ ~Derived2()
+ {
+ cout << "~Derived2 destroyed" << endl;
+ }
+
+ void ChangeAttributes()
+ {
+ cout << "Derived2 Attributes Changed" << endl;
+ }
+
+ Base *Clone()
+ {
+ return new Derived2(*this);
+ }
+};
+
+class Derived3 : public Base
+{
+ public:
+ Derived3()
+ {
+ cout << "Derived3 created" << endl;
+ }
+
+ Derived3(const Derived3& rhs)
+ {
+ cout << "Derived3 created by deep copy" << endl;
+ }
+
+ ~Derived3()
+ {
+ cout << "~Derived3 destroyed" << endl;
+ }
+
+ void ChangeAttributes()
+ {
+ cout << "Derived3 Attributes Changed" << endl;
+ }
+
+ Base *Clone()
+ {
+ return new Derived3(*this);
+ }
+};
+
+// We can also declare "Create" outside Base.
+// But is more relevant to limit it's scope to Base
+Base *Base::Create(int id)
+{
+ // Just expand the if-else ladder, if new Derived class is created
+ // User need not be recompiled to create newly added class objects
+
+ if( id == 1 )
+ {
+ return new Derived1;
+ }
+ else if( id == 2 )
+ {
+ return new Derived2;
+ }
+ else
+ {
+ return new Derived3;
+ }
+}
+//// LIBRARY END
+
+//// UTILITY SRART
+class User
+{
+ public:
+ User() : pBase(0)
+ {
+ // Creates any object of Base heirarchey at runtime
+
+ int input;
+
+ cout << "Enter ID (1, 2 or 3): ";
+ cin >> input;
+
+ while( (input != 1) && (input != 2) && (input != 3) )
+ {
+ cout << "Enter ID (1, 2 or 3 only): ";
+ cin >> input;
+ }
+
+ // Create objects via the "Virtual Constructor"
+ pBase = Base::Create(input);
+ }
+
+ ~User()
+ {
+ if( pBase )
+ {
+ delete pBase;
+ pBase = 0;
+ }
+ }
+
+ void Action()
+ {
+ // Duplicate current object
+ Base *pNewBase = pBase->Clone();
+
+ // Change its attributes
+ pNewBase->ChangeAttributes();
+
+ // Dispose the created object
+ delete pNewBase;
+ }
+
+ private:
+ Base *pBase;
+};
+
+//// UTILITY END
+
+//// Consumer of User (UTILITY) class
+int main()
+{
+ User *user = new User();
+
+ user->Action();
+
+ delete user;
+}
+
diff --git a/english/basic_content/virtual/set3/vir_de.cpp b/english/basic_content/virtual/set3/vir_de.cpp
new file mode 100644
index 0000000..79c7c65
--- /dev/null
+++ b/english/basic_content/virtual/set3/vir_de.cpp
@@ -0,0 +1,41 @@
+/**
+ * @file vir_de.cpp
+ * @brief 派生类的析构函数没有被调用!
+ * 输出结果:
+ * Constructing base
+ * Constructing derived
+ * Destructing base
+ * @author 光城
+ * @version v1
+ * @date 2019-07-24
+ */
+
+// CPP program without virtual destructor
+// causing undefined behavior
+#include
+
+using namespace std;
+
+class base {
+ public:
+ base()
+ { cout<<"Constructing base \n"; }
+ ~base()
+ { cout<<"Destructing base \n"; }
+};
+
+class derived: public base {
+ public:
+ derived()
+ { cout<<"Constructing derived \n"; }
+ ~derived()
+ { cout<<"Destructing derived \n"; }
+};
+
+int main(void)
+{
+ derived *d = new derived();
+ base *b = d;
+ delete b;
+ return 0;
+}
diff --git a/english/basic_content/virtual/set3/virtual_function.cpp b/english/basic_content/virtual/set3/virtual_function.cpp
new file mode 100644
index 0000000..1b6d039
--- /dev/null
+++ b/english/basic_content/virtual/set3/virtual_function.cpp
@@ -0,0 +1,33 @@
+/**
+ * @file virtual_function.cpp
+ * @brief 虚函数可以被私有化,但有一些细节需要注意。
+ * 基类指针指向继承类对象,则调用继承类对象的函数;
+ * int main()必须声明为Base类的友元,否则编译失败。 编译器报错: ptr无法访问私有函数。
+ * 当然,把基类声明为public, 继承类为private,该问题就不存在了。----> 见另外一个例子!
+ * @author 光城
+ * @version v1
+ * @date 2019-07-24
+ */
+
+#include
+using namespace std;
+
+class Derived;
+
+class Base {
+ private:
+ virtual void fun() { cout << "Base Fun"; }
+ friend int main();
+};
+
+class Derived: public Base {
+ public:
+ void fun() { cout << "Derived Fun"; }
+};
+
+int main()
+{
+ Base *ptr = new Derived;
+ ptr->fun();
+ return 0;
+}
diff --git a/english/basic_content/virtual/set3/virtual_function1.cpp b/english/basic_content/virtual/set3/virtual_function1.cpp
new file mode 100644
index 0000000..27648e1
--- /dev/null
+++ b/english/basic_content/virtual/set3/virtual_function1.cpp
@@ -0,0 +1,22 @@
+#include
+using namespace std;
+
+class Derived;
+
+class Base {
+ public:
+ virtual void fun() { cout << "Base Fun"; }
+ // friend int main();
+};
+
+class Derived: public Base {
+ private:
+ void fun() { cout << "Derived Fun"; }
+};
+
+int main()
+{
+ Base *ptr = new Derived;
+ ptr->fun();
+ return 0;
+}
diff --git a/english/basic_content/virtual/set3/virtual_inline.cpp b/english/basic_content/virtual/set3/virtual_inline.cpp
new file mode 100644
index 0000000..ac89964
--- /dev/null
+++ b/english/basic_content/virtual/set3/virtual_inline.cpp
@@ -0,0 +1,44 @@
+/**
+ * @file virtual_inline.cpp
+ * @brief 通常类成员函数都会被编译器考虑是否进行内联。
+ * 但通过基类指针或者引用调用的虚函数必定不能被内联。
+ * 当然,实体对象调用虚函数或者静态调用时可以被内联,虚析构函数的静态调用也一定会被内联展开。
+ * @author 光城
+ * @version v1
+ * @date 2019-07-24
+ */
+
+#include
+using namespace std;
+class Base
+{
+ public:
+ virtual void who()
+ {
+ cout << "I am Base\n";
+ }
+};
+class Derived: public Base
+{
+ public:
+ void who()
+ {
+ cout << "I am Derived\n";
+ }
+};
+
+int main()
+{
+ // note here virtual function who() is called through
+ // object of the class (it will be resolved at compile
+ // time) so it can be inlined.
+ Base b;
+ b.who();
+
+ // Here virtual function is called through pointer,
+ // so it cannot be inlined
+ Base *ptr = new Derived();
+ ptr->who();
+
+ return 0;
+}
diff --git a/english/basic_content/virtual/set4/rtti b/english/basic_content/virtual/set4/rtti
new file mode 100755
index 0000000..c7cb891
Binary files /dev/null and b/english/basic_content/virtual/set4/rtti differ
diff --git a/english/basic_content/virtual/set4/rtti.cpp b/english/basic_content/virtual/set4/rtti.cpp
new file mode 100644
index 0000000..649687e
--- /dev/null
+++ b/english/basic_content/virtual/set4/rtti.cpp
@@ -0,0 +1,34 @@
+/**
+ * @file rtti.cpp
+ * @brief 在面向对象程序设计中,有时我们需要在运行时查询一个对象是否能作为某种多态类型使用。与Java的instanceof,以及C#的as、is运算符类似,C++提供了dynamic_cast函数用于动态转型。相比C风格的强制类型转换和C++ reinterpret_cast,dynamic_cast提供了类型安全检查,是一种基于能力查询(Capability Query)的转换,所以在多态类型间进行转换更提倡采用dynamic_cast
+ * @author 光城
+ * @version v1
+ * @date 2019-07-24
+ */
+
+// CPP program to illustrate
+// // Run Time Type Identification
+#include
+#include
+using namespace std;
+class B { virtual void fun() {} };
+class D: public B { };
+
+int main()
+{
+ B *b = new D; // 向上转型
+ B &obj = *b;
+ D *d = dynamic_cast(b); // 向下转型
+ if(d != NULL)
+ cout << "works"<(obj);
+ cout << "works"<
+int main(void)
+{
+ const int local = 10;
+ int *ptr = (int*) &local;
+
+ printf("Initial value of local : %d \n", local);
+
+ *ptr = 100;
+
+ printf("Modified value of local: %d \n", local);
+
+ return 0;
+}
diff --git a/english/basic_content/volatile/nv b/english/basic_content/volatile/nv
new file mode 100755
index 0000000..b5eb220
Binary files /dev/null and b/english/basic_content/volatile/nv differ
diff --git a/english/basic_content/volatile/volatile.cpp b/english/basic_content/volatile/volatile.cpp
new file mode 100644
index 0000000..fcf6115
--- /dev/null
+++ b/english/basic_content/volatile/volatile.cpp
@@ -0,0 +1,16 @@
+/* Compile code with optimization option */
+#include
+
+int main(void)
+{
+ const volatile int local = 10;
+ int *ptr = (int*) &local;
+
+ printf("Initial value of local : %d \n", local);
+
+ *ptr = 100;
+
+ printf("Modified value of local: %d \n", local);
+
+ return 0;
+}
diff --git a/english/basic_content/vptr_vtable/README.md b/english/basic_content/vptr_vtable/README.md
new file mode 100644
index 0000000..1b82cc6
--- /dev/null
+++ b/english/basic_content/vptr_vtable/README.md
@@ -0,0 +1,219 @@
+# 深入浅出C++虚函数的vptr与vtable
+
+## 关于作者:
+
+个人公众号:
+
+
+
+
+
+## 1.基础理论
+
+为了实现虚函数,C ++使用一种称为虚拟表的特殊形式的后期绑定。该虚拟表是用于解决在动态/后期绑定方式的函数调用函数的查找表。虚拟表有时会使用其他名称,例如“vtable”,“虚函数表”,“虚方法表”或“调度表”。
+
+虚拟表实际上非常简单,虽然用文字描述有点复杂。首先,**每个使用虚函数的类(或者从使用虚函数的类派生)都有自己的虚拟表**。该表只是编译器在编译时设置的静态数组。虚拟表包含可由类的对象调用的每个虚函数的一个条目。此表中的每个条目只是一个函数指针,指向该类可访问的派生函数。
+
+其次,编译器还会添加一个隐藏指向基类的指针,我们称之为vptr。vptr在创建类实例时自动设置,以便指向该类的虚拟表。与this指针不同,this指针实际上是编译器用来解析自引用的函数参数,vptr是一个真正的指针。
+
+因此,它使每个类对象的分配大一个指针的大小。这也意味着vptr由派生类继承,这很重要。
+
+## 2.实现与内部结构
+
+下面我们来看自动与手动操纵vptr来获取地址与调用虚函数!
+
+开始看代码之前,为了方便大家理解,这里给出调用图:
+
+
+
+代码全部遵循标准的注释风格,相信大家看了就会明白,不明白的话,可以留言!
+
+```c++
+/**
+ * @file vptr1.cpp
+ * @brief C++虚函数vptr和vtable
+ * 编译:g++ -g -o vptr vptr1.cpp -std=c++11
+ * @author 光城
+ * @version v1
+ * @date 2019-07-20
+ */
+
+#include
+#include
+using namespace std;
+
+/**
+ * @brief 函数指针
+ */
+typedef void (*Fun)();
+
+/**
+ * @brief 基类
+ */
+class Base
+{
+ public:
+ Base(){};
+ virtual void fun1()
+ {
+ cout << "Base::fun1()" << endl;
+ }
+ virtual void fun2()
+ {
+ cout << "Base::fun2()" << endl;
+ }
+ virtual void fun3(){}
+ ~Base(){};
+};
+
+/**
+ * @brief 派生类
+ */
+class Derived: public Base
+{
+ public:
+ Derived(){};
+ void fun1()
+ {
+ cout << "Derived::fun1()" << endl;
+ }
+ void fun2()
+ {
+ cout << "DerivedClass::fun2()" << endl;
+ }
+ ~Derived(){};
+};
+/**
+ * @brief 获取vptr地址与func地址,vptr指向的是一块内存,这块内存存放的是虚函数地址,这块内存就是我们所说的虚表
+ *
+ * @param obj
+ * @param offset
+ *
+ * @return
+ */
+Fun getAddr(void* obj,unsigned int offset)
+{
+ cout<<"======================="<fun1();
+ cout<<"基类引用指向基类实例并调用虚函数"<fun1();
+```
+
+其过程为:首先程序识别出fun1()是个虚函数,其次程序使用pt->vptr来获取Derived的虚拟表。第三,它查找Derived虚拟表中调用哪个版本的fun1()。这里就可以发现调用的是Derived::fun1()。因此pt->fun1()被解析为Derived::fun1()!
+
+除此之外,上述代码大家会看到,也包含了手动获取vptr地址,并调用vtable中的函数,那么我们一起来验证一下上述的地址与真正在自动调用vtable中的虚函数,比如上述`pt->fun1()`的时候,是否一致!
+
+这里采用gdb调试,在编译的时候记得加上`-g`。
+
+通过`gdb vptr`进入gdb调试页面,然后输入`b Derived::fun1`对fun1打断点,然后通过输入r运行程序到断点处,此时我们需要查看调用栈中的内存地址,通过`disassemable fun1`可以查看当前有关fun1中的相关汇编代码,我们看到了`0x0000000000400ea8`,然后再对比上述的结果会发现与手动调用的fun1一致,fun2类似,以此证明代码正确!
+
+gdb调试信息如下:
+
+```c++
+(gdb) b Derived::fun1
+Breakpoint 1 at 0x400eb4: file vptr1.cpp, line 23.
+(gdb) r
+Starting program: /home/light/Program/CPlusPlusThings/virtual/pure_virtualAndabstract_class/vptr
+基类对象直接调用
+Base::fun1()
+基类引用指向派生类实例
+Base::fun1()
+基类指针指向派生类实例并调用虚函数
+
+Breakpoint 1, Derived::fun1 (this=0x614c20) at vptr1.cpp:23
+23 cout << "Derived::fun1()" << endl;
+(gdb) disassemble fun1
+Dump of assembler code for function Derived::fun1():
+ 0x0000000000400ea8 <+0>: push %rbp
+ 0x0000000000400ea9 <+1>: mov %rsp,%rbp
+ 0x0000000000400eac <+4>: sub $0x10,%rsp
+ 0x0000000000400eb0 <+8>: mov %rdi,-0x8(%rbp)
+=> 0x0000000000400eb4 <+12>: mov $0x401013,%esi
+ 0x0000000000400eb9 <+17>: mov $0x602100,%edi
+ 0x0000000000400ebe <+22>: callq 0x4009d0 <_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@plt>
+ 0x0000000000400ec3 <+27>: mov $0x400a00,%esi
+ 0x0000000000400ec8 <+32>: mov %rax,%rdi
+ 0x0000000000400ecb <+35>: callq 0x4009f0 <_ZNSolsEPFRSoS_E@plt>
+ 0x0000000000400ed0 <+40>: nop
+ 0x0000000000400ed1 <+41>: leaveq
+ 0x0000000000400ed2 <+42>: retq
+End of assembler dump.
+(gdb) disassemble fun2
+Dump of assembler code for function Derived::fun2():
+ 0x0000000000400ed4 <+0>: push %rbp
+ 0x0000000000400ed5 <+1>: mov %rsp,%rbp
+ 0x0000000000400ed8 <+4>: sub $0x10,%rsp
+ 0x0000000000400edc <+8>: mov %rdi,-0x8(%rbp)
+ 0x0000000000400ee0 <+12>: mov $0x401023,%esi
+ 0x0000000000400ee5 <+17>: mov $0x602100,%edi
+ 0x0000000000400eea <+22>: callq 0x4009d0 <_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@plt>
+ 0x0000000000400eef <+27>: mov $0x400a00,%esi
+ 0x0000000000400ef4 <+32>: mov %rax,%rdi
+ 0x0000000000400ef7 <+35>: callq 0x4009f0 <_ZNSolsEPFRSoS_E@plt>
+ 0x0000000000400efc <+40>: nop
+ 0x0000000000400efd <+41>: leaveq
+ 0x0000000000400efe <+42>: retq
+End of assembler dump.
+```
+
diff --git a/english/basic_content/vptr_vtable/img/base.jpg b/english/basic_content/vptr_vtable/img/base.jpg
new file mode 100644
index 0000000..669f2a0
Binary files /dev/null and b/english/basic_content/vptr_vtable/img/base.jpg differ
diff --git a/english/basic_content/vptr_vtable/vptr1.cpp b/english/basic_content/vptr_vtable/vptr1.cpp
new file mode 100644
index 0000000..31f9209
--- /dev/null
+++ b/english/basic_content/vptr_vtable/vptr1.cpp
@@ -0,0 +1,105 @@
+/**
+ * @file vptr1.cpp
+ * @brief C++虚函数vptr和vtable
+ * 编译:g++ -g -o vptr vptr1.cpp -std=c++11
+ * @author 光城
+ * @version v1
+ * @date 2019-07-20
+ */
+
+#include
+#include
+using namespace std;
+
+/**
+ * @brief 函数指针
+ */
+typedef void (*Fun)();
+
+
+/**
+ * @brief 基类
+ */
+class Base
+{
+ public:
+ Base(){};
+ virtual void fun1()
+ {
+ cout << "Base::fun1()" << endl;
+ }
+ virtual void fun2()
+ {
+ cout << "Base::fun2()" << endl;
+ }
+ virtual void fun3(){}
+ ~Base(){};
+};
+
+
+/**
+ * @brief 派生类
+ */
+class Derived: public Base
+{
+ public:
+ Derived(){};
+ void fun1()
+ {
+ cout << "Derived::fun1()" << endl;
+ }
+ void fun2()
+ {
+ cout << "DerivedClass::fun2()" << endl;
+ }
+ ~Derived(){};
+};
+
+/**
+ * @brief 获取vptr地址与func地址,vptr指向的是一块内存,这块内存存放的是虚函数地址,这块内存就是我们所说的虚表
+ *
+ * @param obj
+ * @param offset
+ *
+ * @return
+ */
+Fun getAddr(void* obj,unsigned int offset)
+{
+ cout<<"======================="<fun1();
+ cout<<"基类引用指向基类实例并调用虚函数"<