Why didn't pointer object point
in below example get deleted at the end of program by itself, as other object abc
got deleted? But for pointer object I had to delete it myself, why is that?
#include<iostream>
#include<string>
using namespace std;
class A
{
private:
string name;
public:
A(){
cout << "const called\n";
}
~A(){
cout << "object deleted\n";
}
void setName(string a){
name =a;
}
string getName(){
return name;
}
};
int main()
{
A abc ;
A* point = new A();
abc.setName("Shafaat");
string a =abc.getName();
point->setName("Muhammad");
string b = point->getName();
cout << "name: "<<a << endl;
cout << "name: "<<b << endl;
delete point;
return 0;
}