I know destructor shouldn't not throw exception.
http://www.parashift.com/c++-faq-lite/dtors.html#faq-11.13
I have the following code :
~a()
{
cleanup();
}
// I do not expect exception being thrown in this function.
// If exception really happen, I know that it is something not recoverable.
void a::cleaup()
{
delete p;
}
In...
Section 10.13, Destructors, of the C# Language Specification 3.0 states the following:
Destructors are not inherited. Thus, a class has no destructors other than the one which may be declared in that class.
The Destructors section of the C# Programming Guide contains an example demonstrating how destructors in an inheritance hierar...
Please Note: This question is about the difference in terminology between the words "destructor" and "finalizer" and their correct usage. I have merely provided examples of their use in C# and C++/CLI to demonstrate why I am asking the question. I am well aware of how it is implemented in both C# and the CLR, but I am asking about the co...
Hi,
Does the stack get unwound (destructors run) when a SIGABRT occurs in C++?
Thanks.
...
I am not getting why if there is an active exception then if an exception is raised again, it leads to termination of program. Could someone explain?
...
I had a question about C++ destructor behavior, more out of curiosity than anything else. I have the following classes:
Base.h
class BaseB;
class BaseA
{
public:
virtual int MethodA(BaseB *param1) = 0;
};
class BaseB
{
};
Imp.h
#include "Base.h"
#include <string>
class BImp;
class AImp : public BaseA
{
public:
...
I have a managed object in a c# dll that maintains an anonymous integer handle to an unmanaged object in a c++ dll. Inside the c++ dll, the anonymous integer is used in an std::map to retrieve an unmanaged c++ object. Through this mechanism, I can maintain a loose association between a managed and unmanaged object using an anonymous inte...
When an object is created in your main() function, is its destructor called upon program termination? I would assume so since main() still has a scope( the entire program ), but I just wanted to make sure.
...
I am working on a 3rd party c++ app. It is crashing during the exit. If I look at the stack all I get is the __static_initialization_and_destruction_0 function and lots of questions marks. Project is huge and unfortunately it has many static objects. Is there any way to find out which one is crashing?
...
I am fairly new to learning C# (from Java & C++ background) and I have a question about manual gargabe disposal: is it even possible to manually destroy an object in C#? I know about the IDisposable interface, but suppose I'm dealing with a class I didn't write and it doesn't implement it? It wouldn't have a .Dispose() method, so that an...
Do we need a virtual destructor if my classes do not allocate any memory dynamically ?
e.g.
class A
{
private:
int a;
int b;
public:
A();
~A();
};
class B: public A
{
private:
int c;
int d;
public:
B();
~B();
};
In this case do we need to mark A's destru...
Hi all,
I'm writing a Excel class using Microsoft.Interropt.Excel DLL.
I finish all function but I have an error in my Destructor.
I Want to save all changes to my file and I want to release all source. I want to all of them in my destructor.
But In my destructor, Excel.ApplicationClass, Workbook and Worksheet objects are fill by an Exc...
What are the instances where you need to explicitly call a destructor?
...
I've an object with a certain state. The object is passed around and it's state is temporarly altered. Something like:
public void doSomething(MyObject obj) {
obj.saveState();
obj.changeState(...);
obj.use();
obj.loadState();
}
In C++ it's possible to use the scope of an object to run some code when constructing and di...
Hello,
I'm trying to implement this singleton class. But I encountered this error:
'Singleton::~Singleton': cannot access private member declared in class 'Singleton'
This is flagged in the header file, the last line which contains the closing brace.
Can somebody help me explain what is causing this problem?
Below is my source code.
...
When can an object of a class call the destructor of that class, as if it's a regular function? Why can't it call the constructor of the same class, as one of its regular functions? Why does the compiler stops us from doing this?
For example:
class c
{
public:
void add() ;
c();
~c() ;
};
void main()
{
c objC ;
objC.add() ;...
In my destructor I want to destroy a thread cleanly.
My goal is to wait for a thread to finish executing and THEN destroy the thread.
The only thing I found about querying the state of a pthread is pthread_attr_setdetachstate but this only tells you if your thread is:
PTHREAD_CREATE_DETACHED
PTHREAD_CREATE_JOINABLE
Both of those h...
I'm writing a multi-threaded C++ program. I plan on killing threads. However, I am also using a ref-counted GC. I'm wondering if stack allocated objects get destructed when a thread gets killed.
...
I've got a class (A) that accesses (indirectly via a static method) a static variable (an STL container) in another class (B) in its constructor and destructor.
A objects may be global, global constants, static members of another class, stored in other classes (which may themselves have global or static instances) or basically anywhere ...
Hello
My C++ is a little rusty but I have made a program that reverses a linked list and now I am trying to write the proper destructors for it but I don't know exactly what to destroy. Here are my class definitions:
class LinkedList
{
private:ListElement *start;
public:LinkedList();
public:void AddElement(int val);
publ...