destructor

Is the stack unwound when you stop debugging?

Just curious if my destructors are being called. (Specifically for Visual Studio, when you hit the red stop button) ...

how to Clean up(destructor) a dynamic Array of pointers??

Is that Destructor is enough or do I have to iterate to delete the new nodes?? #include "stdafx.h" #include<iostream> using namespace std; struct node{ int row; int col; int value; node* next_in_row; node* next_in_col; }; class MultiLinkedListSparseArray { private: char *logfile; no...

What's wrong with my destructor?

// Sparse Array Assignment.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> using namespace std; struct node{ int row; int col; int value; node* next_in_row; node* next_in_col; }; class MultiLinkedListSparseArray { private: char *logf...

C++ destructors causing crash's

ok, so i got a some what intricate program that simulates the uni systems of students, units, and students enrolling in units. Students are stored in a binary search tree, Units are stored in a standard list. Student has a list of Unit Pointers, to store which units he/she is enrolled in Unit has a list of Student pointers, to store st...

Base class deleted before subclass during python __del__ processing

Context I am aware that if I ask a question about Python destructors, the standard argument will be to use contexts instead. Let me start by explaining why I am not doing that. I am writing a subclass to logging.Handler. When an instance is closed, it posts a sentinel value to a Queue.Queue. If it doesn't, a second thread will be left ...

GCC destructor behaviour

I've noticed a difference in behaviour for gcc's destructor when compiled under linux and crosscompiled with mingw. On linux the destructor will not get called unless the program terminates normally by itself (returns from main). I guess that kind of makes sense if you take signal handlers into account. On Win32 however, the destructor...

lua userdata c++ destructor

In lua, for memory allocated with lua_newuserdata, is it possible to register a destructor, so that the destructor is called when the memory region is garbage collected by lua? Thanks! ...

Which method can I override for cleanup task when a Tkinter.Tk window in Python?

Hello. I created: class MainGUI(Tkinter.Tk): # some overrides # MAIN gui = MainGUI(None) gui.mainloop() But I need to do some cleanup when the window is closed by the user. Which method in Tkinter.Tk can I override? ...

base destructor called twice after derived object?

hey there, why is the base destructor called twice at the end of this program? #include <iostream> using namespace std; class B{ public: B(){ cout << "BC" << endl; x = 0; } virtual ~B(){ cout << "BD" << endl; } void f(){ cout << "BF" << endl; } virtual void g(){ cout << "BG" << endl; } private: int x; ...

destructor and copy-constructor calling..(why does it get called at these times)

Hello there, I have the following code #include <iostream> using namespace std; class Object { public: Object(int id){ cout << "Construct(" << id << ")" << endl; m_id = id; } Object(const Object& obj){ cout << "Copy-construct(" << obj.m_id << ")" << endl; m_id = obj.m_id; } Object& oper...

Safe placement new & explicit destructor call

This is an example of my codes: template <typename T> struct MyStruct { T object; } template <typename T> class MyClass { MyStruct<T>* structPool; size_t structCount; MyClass(size_t count) { this->structCount = count; this->structPool = new MyStruct<T>[count]; for( size_t i=0 ; i<count ; i++ ) ...

C++ Virtual Destructors

When creating prototype classes I lay out the destructor as such: virtual ~MyClass(); When finalizing the class in a library I noticed that I cannot add 'virtual'. Is this normal, and is virtual taken into consideration or am I do something wrong? For example; when I try to do this I get a compiler error: virtual MyClass::~MyClass()...

Pure virtual destructor in interface

Hello all. Here is my problem. I'm making C++ dll, which extensively relies on instance object exports. So i return my actual instances as a pointers to interface through some exported factory method. Interfaces i use are purely virtual, to avoid linking problame. So i need a pure virtual destructor too, and i implemented one (with emp...

C++ destructor problem with boost::scoped_ptr

I have a question about the following code: #include <iostream> #include <boost/scoped_ptr.hpp> class Interface { }; class A : public Interface { public: A() { std::cout << "A()" << std::endl; } virtual ~A() { std::cout << "~A()" << std::endl; } }; Interface* get_a() { A* a = new A; return a; } int main(...

Can a destructor be recursive?

Is this program well-defined, and if not, why exactly? #include <iostream> #include <new> struct X { int cnt; X (int i) : cnt(i) {} ~X() { std::cout << "destructor called, cnt=" << cnt << std::endl; if ( cnt-- > 0 ) this->X::~X(); // explicit recursive call to dtor } }; int main(...

Destructors in Lua?

Is it possible to get destructors in Lua w/o using userdata? http://www.lua.org/notes/ltn006.html looks promising (in fact exactly what I want); except it's a path for Lua 4.0. Basically, I want a way to have a function called when a table is collected. Thanks! ...

c++ must delete a references?

hello community, how are you? in the following code: class x { private: someRef& m_ref; public: x(someRef& someRef):m_ref(someRef) { } do I need to do: ~x() { delete m_ref; } which by the way doesnt work without getting the pointer... basically I'm asking: Do I need to call a destructor on a reference member? ...

Why aren't (C++) virtual destructors enforced for a base class

Destructors aren't virtual by default to not hurt when its not needed, which is fine. But in case of a base class derived class scenario, is there any use case for not having a virtual destructor? If not could it be possible (does it make sense) for the compiler to complain if a class derives from a base class which has a public non vir...

Calling Destructor within Object Method in PHP

I have an object that can be used, or eaten, or whatnot in PHP. In any case, it ends up gone. I have an abstract protected method called activate(), which is called by a public method useItem(). Is it possible for useItem() to destroy itself after calling activate()? If not, what is the best way of making sure the item is permanently g...

wxPython App - Ensure All Dialogs are Destroyed

I'm working on an application that will need to use a variety of Dialogs. I'm having trouble getting events bound in a way that ensures that my Dialogs are destroyed properly if someone closes the application before dismissing the dialogs. I would expect to use something like this: class Form(wx.Dialog): def __init__(self): wx.Dial...