when constructor leave will memory will leak?
Here is the code
Code:
class Someclass
{
private:
SomeOtherclass* p;
public:
Someclass()
{
p=new SomeOtherclass;
}
}
while connstructing the object of the calss
Someclass* sp= new Someclass;
first momory will be allocated to sp (here 4 byte as it only conatins a pointer to calss).Then Someclass's contructor will be called which will allocate memeory to p.If this fails, what will happen?
Momory allocated for sp will be leacked, right?
How are the way to chk this?
Thanks and regards!