Reputation: 1
it's a simple question but i don't find answer.
I start to work with the new c++ return value syntax. For example :
class A
{
// Old syntax
float foo();
// New syntax
auto foo() ->float;
};
But i don't know how to do the same thing for const method
class A
{
// Old syntax
float foo() const;
// New syntax
auto foo() ->float const;
};
Always detecting as returning const float. If someone know how to write correctly this kind of method, thank you in advance.
Upvotes: 0
Views: 85
Reputation: 234785
auto foo() const -> float;
is the syntax.
The return type is float
, not const float
, and the function itself is a const
member.
Note that you are allowed to use one format in the declaration and the other in the definition.
Upvotes: 3