0

What's the difference between having a const function and declaring const after the function? For example, if I had a class Myclass with some private data members and I set up a public function called int getMyValue(), what would the difference be between declaring that function as:

const int getMyValue();

and

int getMyValue() const;

Edited by sfurlow72: n/a

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by L7Sqr
1

The first example associates the const-ness with the value returned from the call. In the second example you are specifying that the call can not modify the object being invoked.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.