STL-error?
Hmm, I think something's wrong in the destructor of the class.
Could it be that because I don't have an (empty) virtual destructor in a derived class, that it gives the error? In what cases is a virtual destructor needed when using polymorphism?
[edited by - Jedyte on June 4, 2003 1:03:15 PM]
Could it be that because I don't have an (empty) virtual destructor in a derived class, that it gives the error? In what cases is a virtual destructor needed when using polymorphism?
[edited by - Jedyte on June 4, 2003 1:03:15 PM]
Usually always. Certainly any time those instances might be deleted via a pointer to a base class.
[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]
[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]
Got it! Thanks Kylotan, your idea brought me back on track.
It was a stupid list::back() when the list was empty. Cheez, I've been programming in STL for over 4 years, you'd think I'd wouldn't make such a mistake anymore %)
To return to my other question now that we're on it, if I write this, will the destructors be called correctly?
[edited by - Jedyte on June 4, 2003 1:33:20 PM]
It was a stupid list::back() when the list was empty. Cheez, I've been programming in STL for over 4 years, you'd think I'd wouldn't make such a mistake anymore %)
To return to my other question now that we're on it, if I write this, will the destructors be called correctly?
class Base{ Base(); virtual ~Base(); // virtual here};class Derived: public Base{ Derived(); // but nothing here, we don't need it};
Thanks.[edited by - Jedyte on June 4, 2003 1:33:20 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement