& in a function declaration

This line of code was in the public section of a Class:

 
inline string& Name();  //Name reference 


Can someone explain the significance of the &? How does this affect the function?
std::string & func(); // Means it's a function that returns a reference to std::string

For example:

1
2
3
4
5
6
class MyClass{
private:
	std::string name;
public:
	std::string & Name(){ return name;};
}


So with Name() function you can modify private member "name" like Name() = "my_name".
Last edited on
Topic archived. No new replies allowed.