Which destructor is called when in C++?

Doh. I only ever went a few steps into ~CMain. But you are correct.It never reaches the end of ~CMain.

– BastiBechtold Dec 22 '10 at 10:57 1 Congrats. Then will some more debugging, you may eventually find why it's not called.PS: checking the disassembly code may help. – wqking Dec 22 '10 at 11:08.

Maybe there is a slicing problem somewhere. Just guessing.. What is the slicing problem in C++? No, this is not that case.

You shuld put a try catch block in ~CMain, hmmm one of its member throw an exception in a destructor?

But here it seems base class destructors are not getting called. – Naveen Dec 22 '10 at 10:56 Yes, this is not that case – Industrial-antidepressant Dec 22 '10 at 11:00.

Because you don't delete your object allocated with new. ;-) More seriously, do you have gone into debugging the theoritical end of scope of one of your CList, and step into its destruction process, what happens?

CMain gets deallocated just fine, but ~CList() is never called. That sounds like a wrong statement. If ~CMain is called, then ~CList is eventually called too, because it's a base class.

Check how you detect whether or not a destructor is called. When you say "CMain gets deallocated", do you mean to say you issue delete on it? Check that at the point you do delete pMain, the class definition of CMain is visible.In absence of its definition, the compiler is allowed to assume the class doesn't have a user defined or virtual destructor, and can omit calling it.

Child, then parent. But in between them, the attributes of the child are destroyed. I would suggest seeing if ~CMain runs to the end - if it does, and ~CList is never entered, you have a problem with one of the attributes of CMain.

Just to demonstrate: #include #include struct Owned { ~Owned() { std::cerr.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions