Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Is there an issue in your c++ version where your risking a segfault when Foo(99) goes out of scope but you reference it in your main method? Commented Jun 15, 2016 at 8:14
  • Indeed. Ah comes from using java for 10 years. But the idea still holds. And I fixed it now. Commented Jun 16, 2016 at 15:16
  • I think the previous was better because it would compile. I was just curious about the behavior, sorry about that. Commented Jun 16, 2016 at 17:41
  • 1
    This answer only helps for those coming from C++ background who are willing to define "reference" the way you have, according to C++'s definition. That is not always the case. Commented Aug 2, 2017 at 15:41
  • "What is the outcome?" - Guess a memory leak Commented Dec 6, 2021 at 18:53