C++: returning by reference and copy constructors

后端 未结 9 1819
伪装坚强ぢ
伪装坚强ぢ 2020-12-09 09:46

References in C++ are baffling me. :)

The basic idea is that I\'m trying to return an object from a function. I\'d like to do it without returning a pointer (because

9条回答
  •  不知归路
    2020-12-09 10:22

    Not a direct answer, but a viable suggestion: You could also return a pointer, wrapped in an auto_ptr or smart_ptr. Then you'll be in control of what constructors and destructors get called and when.

提交回复
热议问题