c++ - What does empty destructor do? -
i heard empty destructor doesn't , calling doesn't remove object. in code:
#include <iostream> #include <set> class { public: ~a() {} std::set <int> myset; }; int main() { object; object.myset.insert(55); object.~a(); object.myset.insert(20); std::cout << object.myset.size(); }
i get: "* glibc detected * /.app: double free or corruption (fasttop):" , "abort".
if matters have c++11 flag enabled. empty constructor do? , read doesn't.
your destructor may empty, it's destructing fellow member variables. in case, it's destructing myset
, subsequent insert(20)
crashing.
if class had no non-pod fellow member variables empty destructor nothing.
c++ destructor
No comments:
Post a Comment