const return type?

I assume that when a function is declared like below. The const keyword marks the return type as constant. Am i correct in this assumption?

 
 int SomeFunction()const;
No. It states that the function will not modify the object that you call it on.

If you look at the std::string::size() function for instance, you will see it's marked as const.
http://www.cplusplus.com/reference/string/string/size/
1
2
std::string str = "hello";
std::cout << str.size() << std::endl;
So after we have called the size() function we can be sure the string has not changed.

When you have a const object you can only call functions marked as const.
1
2
3
const std::string str = "hello".
str.size();     // OK.
str.resize(10); // error: resize is not a const function 
Ok, thanks for the reply Peter87.
Topic archived. No new replies allowed.