What means '&' before getter?
const std::string &getName() const {
return Name;
}
getter was generated by CLion ide
What means '&' before getter?
const std::string &getName() const {
return Name;
}
getter was generated by CLion ide
It's part of the return value's data type.
Rearranging whitespace,
const std::string&
getName()
const
{...}
This is a function named getName
which takes no parameters, doesn't modify object members, and which returns a value of type const std::string&
. This data type can be read as "reference to a const string".