General Question
Is it possible to return an entire linked list object from a method in C++ without running the destructor?
Asked by HeroicZach (195)
October 8th, 2009
Basically I’m designing a C++ class where one of the class functions has it return another object of that same class (return myClass;). This class uses dynamic memory management (linked lists) in order to function properly.
When C++ returns the class, it’s really only returning the head reference, then, when it runs the destructor after the class function exits, it deletes all the nodes to which the head is linked.
Is there any way to really do this right?
Observing members:
0
Composing members:
0
4 Answers
Answer this question
This question is in the General Section. Responses must be helpful and on-topic.
Have a question?
Ask Fluther!