Can i change the value of a reference return?

If i have a class like this:
1
2
3
4
5
6
7
8
9
10
class Foo {
private:
int inum;
public:
int & get_value() 
{
return inum;
}
...
};


then, does this statement change the value of the private data member?
1
2
Foo Foobj;
Foobj.get_val() = 8;

Thanks !
Yes, which is why getters normally return constant references (const T *).
Oh, i see...Thanks!
Topic archived. No new replies allowed.