-
November 15th, 2011, 03:00 PM
#1
Is that sample code correctly?
Could you say me is that code fully correctly?
A Fun()
{
A a = 0;
return a;
}
const A& a = Fun();
A b = a;
-
November 15th, 2011, 03:15 PM
#2
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|