R
raj s
Will the below code cause memory leak in c++
class base{
int a;
int *pint;
someclass objsomeclass;
someclass* psomeclass;
base(){
objsomeclass = someclass();
psomeclass = new someclass();
pint = new int();
throw "constructor failed";
a = 43;
}
}
main(){
base temp();
}
in the above code constructor fails.Which objects will be leaked and
how to avoid memory leak and even if destructor is called for
automatic object is temp and temp pointer will leak the memory?
main(){
base *temp = base();
}
what about in the above code and how to avoid memory leak when
constructor fails
class base{
int a;
int *pint;
someclass objsomeclass;
someclass* psomeclass;
base(){
objsomeclass = someclass();
psomeclass = new someclass();
pint = new int();
throw "constructor failed";
a = 43;
}
}
main(){
base temp();
}
in the above code constructor fails.Which objects will be leaked and
how to avoid memory leak and even if destructor is called for
automatic object is temp and temp pointer will leak the memory?
main(){
base *temp = base();
}
what about in the above code and how to avoid memory leak when
constructor fails