Hi,
As per below code snippet it is clear that in below class a if we don't introduce assignment operator
despite of having pointer values it works fine as memory allocation is done explicitly by declaring s2 object on heap .
can anybody suggest, if same canbe achieved without declaring copy constructor explicitly despite of having pointer fields .
class A
{
int *m_p;
string str;
public:
A (string );
void setVal(int);
~a (){
delete m_p;
}
}
};
A s1("s1") ;
A * s2 = new A ("s2");
s2=&s1;
delete s2;
~Mohan