November 15th, 2011, 03:00 PM
Is that sample code correctly?
Could you say me is that code fully correctly?
A a = 0;
const A& a = Fun();
A b = a;
November 15th, 2011, 03:15 PM
Re: Is that sample code correctly?
to say it's "fully" correct, you should show us the definition of A ...
anyway, supposing that A is non-explictly constructible from an int and that it is also copy constructible, it's correct.
if you have doubts about the line "const A& a = Fun();", note that a temporary bound to a const reference will survive up to the end of the scope in which the reference is defined; so, again, it's ok.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!