S
shaun roe
A basic question, inspired by code in 'exceptional c++ style' pg. 124:
The example code illustrates accessor functions instead of making data
public.
To paraphrase:
Class X {
public:
T1& UseT1() {return t1_;}
private:
T1 t1_;
};
I would have written: T1 UseT1() {return t1_;}, so my question is:
t1_ is just returned (as a value?) so what does the '&' do in the return
type definition? Does it really return a reference to the internal
value? What are the ownership/lifetime implications of 'T1 &' versus
'T1' ?
cheers
shaun
The example code illustrates accessor functions instead of making data
public.
To paraphrase:
Class X {
public:
T1& UseT1() {return t1_;}
private:
T1 t1_;
};
I would have written: T1 UseT1() {return t1_;}, so my question is:
t1_ is just returned (as a value?) so what does the '&' do in the return
type definition? Does it really return a reference to the internal
value? What are the ownership/lifetime implications of 'T1 &' versus
'T1' ?
cheers
shaun