Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8117605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:13:43+00:00 2026-06-06T04:13:43+00:00

I have this one class: say InterClass . This class is declared in say,

  • 0

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 🙁 )

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T04:13:44+00:00Added an answer on June 6, 2026 at 4:13 am

    Clearly, this smells of not obeying the Rule of Three.
    Your class Copy constructor and Copy assignment operator should do a deep copy of the dynamically allocated member pointer. If not then you are bound to see the behavior you get.

    Either way you should avoid using a raw pointer member to being with.You are much better off wrapping it up in a Smart pointer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have this class: public abstract class CustomerCollectionBase : Collection<Customer>{} One of
Let's say I have a custom class like this one: public class Customer {
I have a problem.... Lest say I have a class like this one: public
I have a class that contains a boolean field like this one: public class
Let's suppose I have xml like this one: <Server Active=No> <Url>http://some.url</Url> </Server> C# class
Lets say I have this: public class Result { public bool Success { get;
let's say I want my users to use only one class, say SpecialData. Now,
Say I have this class: class A { private $var_a, $var_b; public function do_something(){
Let's say I have this code: class Score { public Update(int score) { update
Just wondering how people would go about this. Say I have one class that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.