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, 14 February 2018
C++, an empty destructor for a class
Subscribe to:
Post Comments (Atom)
casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV
In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...
-
I'm using Simple HTML DOM to extract data from a HTML document, and I have a couple of issues that I need some help with. On the line th...
-
I've just started to learn CodeIgniter and gotten trouble with example below: My Controller: class Site extends CI_Controller ...
-
I've got a just installed ubuntu 11.10. I follow the first answer in this question. I installed: freeglut3 freeglut3-dev igor@ubuntu:~$...
No comments:
Post a Comment