Is that sample code correctly?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: Is that sample code correctly?

  1. #1
    Join Date
    Nov 2011

    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;

  2. #2
    Join Date
    Oct 2008

    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

Azure Activities Information Page

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


HTML5 Development Center