+ 1
Basic Question : why pointer to class is needed
Refer code below: It is a sample code and depict a scenarion in production code. Like here we create obj in main method and it is passed to a method is my implementation. It works as we dont create copy due to pass by reference and destructor is also called due to obj created on stack. Now what I saw is a production code having unique pointer of test class instead of object on stack.it was moved to testmethod as it was not needed post that method... there also destructor was called Now two questions : 1. If in this case no smart pointer is created and just stack object is used like i have in sample codrle, is there any issue predicted ? 2. When heap allocation is prefered ? https://code.sololearn.com/c3K3RXt8d62F/?ref=app
2 Respostas
+ 2
can you give us the production code example ..
I am unable to clearly get what you're asking for.
0
Updated same code now.
Testmethod is now part of class and does not take any input argument.
two different methods called from main function are replication of production code and my suggestion.