C ++ function has a rear const

Add back non-static member function const, similar to the following functions:

class testClass{
public:
    void testClass() const{ /*...*/}
private:
    /*...*/
};

 

The member function implicitly passed this pointer is const pointer,

In this decision the member function, any modification operations in which it is a member of the class are not allowed, because of this implicit const pointer references.

That is the value of an object member variable does not change.

 

reference:

https://stackoverflow.com/questions/2157458/using-const-in-classs-functions

Guess you like

Origin www.cnblogs.com/hellowooorld/p/11279606.html