BOOL operator== (const array&) const; What is this last const for?

Source: Internet
Author: User

Character overloading is also a function, and a function such as const at the end of a function is called a constant member function. The constant member function can be understood as a "read-only" function, which cannot change the value of a data member or invoke a member function that can cause a change in the value of a data member, only the const member function.

The first guarantees that an explicit call is not modified, and the second guarantees that the implicit call is not modified.

The const is put in the last member function called the constant function, which is used to prevent the member data of this class from being modified in this function. If modified, a compilation error occurs. This overload cannot change the variable you are referencing (array&).

Such as:

BOOL operator== (const array&) const; What is this last const for?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.