I have this one class: say "InterClass".
This class is declared in say, MainClass as:
in MainClass.h :
public:
    InterClass *m_pInterClass; 
and in Constructor of MainClass:
m_pInterClass = new InterClass(this);
I want to use some functions of MainClass in InterClass, so passing this in constructor. I assign this to a global pointer and use it everywhere in class.
In main() everything works fine until it reaches to end. 
Last lines of my code are:
delete MainClass;
OutputDebugString("Exiting Application");
return 0;
My Application crashes at "return 0"
I put OutputDebugString() everywhere in my code.
What I narrowed down is:
On DebugView- 
 I can see Destructor of "InterClass" getting executred then "Exiting Application" and then again Destructor of "InterClass" executes.
I am confused why destructor of InterClass gets executed twice? that to at return 0;
I can't put breakpoint in this application due to nature of this application.
P.S. I am an Embedded C programmer and completely new to C++ (who is forced to work on PC application :( )
 
     
     
    