const
at the end of a function signature means that the function must accept an object of which it is a member. In practice, this means that you ask the compiler to verify that the member function is not modifying the object data in any way. This means that the compiler must verify that it does not directly modify the data of the element, and does not call any function that does not guarantee itself that it will not change the object.
When you create a const
object, you ask the compiler to make sure that this object has not changed beyond its initialization. This in turn means that the compiler verifies that you are not directly modifying its member data, and that you are not calling any function that does not guarantee that it will not modify the object.
This is all part of the philosophy of const correct . In essence, this means that if everything works right now, and they do not change, they will never break. In other words, persistent things are easier to work with reliability. This const
thing at the end of function signatures is a tool that allows you to prohibit broadcasting. This in turn means that you should put const
wherever possible.
wilhelmtell Oct 30 '10 at 18:16 2010-10-30 18:16
source share