constant members cannot be updated

https://github.com/huihut/interview/issues/78
https://github.com/huihut/interview/issues/77
This commit is contained in:
huihut 2021-04-14 00:27:04 +08:00
parent e6dbc2b9c3
commit 191b30533e
3 changed files with 3 additions and 3 deletions

View File

@ -97,7 +97,7 @@ public:
void function() void function()
{ {
// 对象 // 对象
A b; // 普通对象,可以调用全部成员函数、更新常成员变量 A b; // 普通对象,可以调用全部成员函数
const A a; // 常对象,只能调用常成员函数 const A a; // 常对象,只能调用常成员函数
const A *p = &a; // 指针变量,指向常对象 const A *p = &a; // 指针变量,指向常对象
const A &q = a; // 指向常对象的引用 const A &q = a; // 指向常对象的引用

View File

@ -102,7 +102,7 @@ public:
void function() void function()
{ {
// object // 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 a; // constant object, can only call constant member functions
const A *p = &a; // pointer variable, point to a constant object const A *p = &a; // pointer variable, point to a constant object
const A &q = a; // reference to constant object const A &q = a; // reference to constant object

View File

@ -90,7 +90,7 @@ public:
void function() void function()
{ {
// 对象 // 对象
A b; // 普通对象,可以调用全部成员函数、更新常成员变量 A b; // 普通对象,可以调用全部成员函数
const A a; // 常对象,只能调用常成员函数 const A a; // 常对象,只能调用常成员函数
const A *p = &a; // 指针变量,指向常对象 const A *p = &a; // 指针变量,指向常对象
const A &q = a; // 指向常对象的引用 const A &q = a; // 指向常对象的引用