N
Neelesh Bodas
Hi all,
suppose the ctor of the class throws. Thus, at this point in time, some
memory has been allocated but the object couldnot be constructed. Also,
the memory is not yet freed. Does the c++ std automatically guarantee
the call to operator delete?
The relavent code is :
class Int {
public:
Int()
{
throw 100;
}
~Int()
{
// this will never be called, since the ctor throws.
}
};
int main()
{
Int *p = new Int;
// will p be deleted at this point without doing an explicit call to
delete (provided the ctor throws)?
}
TC++PL Edition 3, 14.4.5 says that the memory should be freed. But it
doesnot say clearly whether it will be freed by calling operator
delete() or something else.
Thanks in advance
Neelesh,
suppose the ctor of the class throws. Thus, at this point in time, some
memory has been allocated but the object couldnot be constructed. Also,
the memory is not yet freed. Does the c++ std automatically guarantee
the call to operator delete?
The relavent code is :
class Int {
public:
Int()
{
throw 100;
}
~Int()
{
// this will never be called, since the ctor throws.
}
};
int main()
{
Int *p = new Int;
// will p be deleted at this point without doing an explicit call to
delete (provided the ctor throws)?
}
TC++PL Edition 3, 14.4.5 says that the memory should be freed. But it
doesnot say clearly whether it will be freed by calling operator
delete() or something else.
Thanks in advance
Neelesh,