Question: Create a class called Point with two private data members, a public print function, and constructors as well as a destructor that prints a message

Create a class called Point with two private data members, a public print function, and constructors as well as a destructor that prints a message when it is called. Then create an array of 10 Points on the stack, initialize them with non-zero data, and print them. Verify that that the destructor is called for all 10 points when your program exits. Finally, create an array of 10 Points on the heap, initialize them with non-zero data, and print them. Do not delete the array and verify the destructor is not called (you have created a memory leak). Now write your program to delete the array at the end. Verify that only one destructor is called and your program crashes (you have created a memory leak and a bug). Now write your program to delete[] the array at the end. Verify that all destructors are called. Please use the names of classes and functions specified and don't over-complicate the solution. Complete in C++

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!