I've read one of your answers (Will an 'empty' constructor or destructor do the same thing as the generated one?). You wrote:
"Let's assume the object of type C is created in the definition of A's constructor in the .cpp file, which also contains the definition of struct C. Now, if you use struct A, and require destruction of an A object, the compiler will provide an implicit definition of the destructor, just like in the case above. That destructor will also implicitly call the destructor of the auto_ptr object. And that will delete the pointer it holds, that points to the C object - without knowing the definition of C! That appeared in the .cpp file where struct A's constructor is defined". Could you please explain 2 things for me:
1. why should the destructor of A know C's definition?
2. How does adding A's empty destructor help the sityation?
Thank you
Wednesday, February 14, 2018
C++, an empty destructor for a class
Subscribe to:
Post Comments (Atom)
plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV
In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...
-
When the left part is an object instance, you use -> . Otherwise, you use :: . This means that -> is mostly used to access instance m...
-
This question attempts to collect the few pearls among the dozens of bad C++ books that are published every year. Unlike many other programm...
-
Possible Duplicates: Deep copy vs Shallow Copy In Java, what is a shallow copy? What is the difference between a deep copy and a s...
No comments:
Post a Comment