Deleting pointer data using a deconstuctor

Hello everyone I am trying to ensure that I have now memory leaks within my program that I am working on for school. I am having problems ensuring that my object data is being successfully removed through a deconstructor. I run the program with the code I am listing and end with no errors but on when I follow the program I see that I am not actually deleting the object rather empty the contents with the object framework still in place. Any help would be greatly appreciated.

Deconstructor Implementation in the cpp file
1
2
3
4
5
  Account::~Account()
{
	delete psn;
	psn = nullptr;
}// end deconstructor 


Prototype in the header
1
2
3
4
5
  // De-Constructor
  // Purpose: Remove all dynamic data.
  // Parameters: none
  // Returns: none
  virtual ~Account();


I am removing content but not framework
closed account (SECMoG1T)
Hello, what is "psn" pointing to and how did you come to this
I see that I am not actually deleting the object rather empty the contents

Hello, what is "psn" pointing to and how did you come to this


Declared in Header

1
2
protected:
	Person *psn;    // An object of the Person class 


Implemented in cpp

1
2
3
4
5
6
7
8
9
10
11
12
Account::Account()
{
	accountNumber = "none";
	accountBalance = 0.00;
	psn = new Person();
}// End nonparamterized account constructor

Account::Account(Person* _person, string _accountNumber, double _accountBalance)
{
	psn = _person;
	accountNumber = _accountNumber;
	accountBalance = _accountBalance;


So I am using persistence within the classes and protecting Person as I have to be able to see it within a checking and as savings account.

Thanks again
That doesn't answer andy1992's question. How do you know you are not deleting the object?
I am looking at the local data-members and inserting breakpoints within the program an up until the last line of program the return in main the framework of the person array is visible no data is in the array but the array is there and if I understand correctly that is a memory leak.

If not then I am simply not understanding the concept of the memory leak.
but the array is there
How do you know that? Are you sure that it is not the issue of debugger continuing to show content of actual memory regardles of the fact if it was deallocated?

Can you create a minimum working example reproducing your problem and post it along with your compiler name and screenshot confirming the problem?
I double checked what I was seeing and I did successfully remove the array out of the heap I just had a break that was prior to the removal after double checking here and with others I seem to have completed the assignment just need to work a little more on how to use the debugger more efficiently.

Thanks for all your help
Topic archived. No new replies allowed.