#include<iostream>
#include<conio.h>
using namespace std;
class A
{
public:
int *p;
A()
{
p =new int;
}
~A()
{
delete p; //Is this what i am doing is correct?
cout << "in A's destructor"<<endl;
}
};
int main()
{
A *obj=new A;
delete obj;
getch();
}
This programs,i have executed in Dev c++ and compiles and executes fine.
But i doubt this is not fine.Specially in the destructor where i say delete P
am i wrong?