Question: In C++ 1.Create a class called Point with two private data members, a public print function, and constructors as well as a destructor that prints
In C++
1.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.
2.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.
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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
