#include<iostream>
#include<string>
class A
{
public:
A()
{
std::cout << "constructed." << std::endl;
}
~A()
{
std::cout << "destructed." << std::endl;
}
};
int main()
{
A *ao = new A();
A* ab;
ab = ao;
delete ab; // also deletes the object constructed on heap memory.
int* int1 = newint(20);
int* int2;
int2 = int1;
delete int2; //this does not delete the int1 created on heap.
}
what is difference between deleting these two primitive type pointer and class type pointer.