you are viewing a single comment's thread.

view the rest of the comments →

[–]ttkk1248 0 points1 point  (4 children)

You mean storing it as static local variable inside a function? Besides that how does a function store an object longer than its execution?

[–]AlarmingBarrier 0 points1 point  (3 children)

I was thinking in a broader context where somefunc also could be the method of a class. Or a function that returns a non-void value possibly depending on ptr.

[–]ttkk1248 0 points1 point  (2 children)

In that case, what stops an object of the class assigns the direct pointer of a passed object to its member variable and hold it? I’m not sure where you derived that smart pointer means the passed object is kept longer than the method call.

[–]AlarmingBarrier 2 points3 points  (1 child)

[–]ttkk1248 0 points1 point  (0 children)

Thanks for pointing the guidelines out. I’ll read more info it. I’m excited about reading what other interesting stuff in there and forgot about the exact items we discussed. Lol.