diff --git a/README.md b/README.md index 12c43e1..9a581b6 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ * 自身是常量的指针(常量指针,const pointer) * 引用 * 指向常量的引用(reference to const) - * 没有 const reference,因为引用本身就是 const pointer + * 没有 const reference,因为引用只是对象的别名,引用不是对象,不能用 const 修饰 > (为了方便记忆可以想成)被 const 修饰(在 const 后面)的值不可改变,如下文使用例子中的 `p2`、`p3` @@ -82,7 +82,7 @@ const 使用 class A { private: - const int a; // 常对象成员,只能在初始化列表赋值 + const int a; // 常对象成员,可以使用初始化列表或者类内初始化 public: // 构造函数 diff --git a/README_en.md b/README_en.md index 3f9a2c0..9ff2de5 100644 --- a/README_en.md +++ b/README_en.md @@ -71,9 +71,9 @@ English * Pointer * Pointer to const * A pointer to a constant itself (const pointer) -* Quote +* Reference * Reference to const - * There is no const reference because the reference itself is a const pointer + * There is no const reference because the reference is an alias of an object, the reference is not an object > (Think of it for convenience) The value modified by const (after const) cannot be changed, such as `p2`, `p3` in the usage example below @@ -87,7 +87,7 @@ const use class A { private: - const int a; // constant object member, can only be assigned in the initialization list + const int a; // constant object member, can use initialization list or in-class initializer public: // Constructor diff --git a/docs/README.md b/docs/README.md index c34ae1e..3e3a384 100644 --- a/docs/README.md +++ b/docs/README.md @@ -62,7 +62,7 @@ * 自身是常量的指针(常量指针,const pointer) * 引用 * 指向常量的引用(reference to const) - * 没有 const reference,因为引用本身就是 const pointer + * 没有 const reference,因为引用只是对象的别名,引用不是对象,不能用 const 修饰 > (为了方便记忆可以想成)被 const 修饰(在 const 后面)的值不可改变,如下文使用例子中的 `p2`、`p3` @@ -75,7 +75,7 @@ const 使用 class A { private: - const int a; // 常对象成员,只能在初始化列表赋值 + const int a; // 常对象成员,可以使用初始化列表或者类内初始化 public: // 构造函数 diff --git a/docs/en.md b/docs/en.md index 57d352c..68336b3 100644 --- a/docs/en.md +++ b/docs/en.md @@ -64,9 +64,9 @@ * Pointer * Pointer to const * A pointer to a constant itself (const pointer) -* Quote +* Reference * Reference to const - * There is no const reference because the reference itself is a const pointer + * There is no const reference because the reference is an alias of an object, the reference is not an object > (Think of it for convenience) The value modified by const (after const) cannot be changed, such as `p2`, `p3` in the usage example below @@ -80,7 +80,7 @@ const use class A { private: - const int a; // constant object member, can only be assigned in the initialization list + const int a; // constant object member, can use initialization list or in-class initializer public: // Constructor @@ -95,7 +95,7 @@ public: void function() { // object - A b; // ordinary object, can call all member functions, update constant member variables + A b; // ordinary object, can call all member functions const A a; // constant object, can only call constant member functions const A *p = &a; // pointer variable, point to a constant object const A &q = a; // reference to constant object