Gabriel
Thu Feb 24 16:29:55 CST 2005
"William DePalo [MVP VC++]" <willd.no.spam@mvps.org> wrote in message
news:O6q0j5rGFHA.1996@TK2MSFTNGP12.phx.gbl...
> "Gabriel Bogdan" <na@na.na> wrote in message
> news:e8aIkUrGFHA.3068@tk2msftngp13.phx.gbl...
> > As I sed, this form of delete operator does work, but I also see this at
> > compile time:
> > "c:\Proiecte\ClassesTest\ClassesTest.cpp(54) : warning C4291: 'void
> > *TmpB::operator new(size_t,void *)' : no matching operator delete found;
> > memory will not be freed if initialization throws an exception"
>
> You might want to take a look at this link
>
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_pluslang_the_new_and_delete_operators.asp
>
> and read about the interaction of exceptions and new operators.
>
> (Sorry to ask but I don't save posts) Did you post the code for _all_ of
the
> new and delete operators defined in your class?
They are just dummys right now, empty functions.
The idea is that you need 2 types of delete operators (the documentation
dosn't really tell you this, as I read it).
void* operator new(size_t Size, void* tag)
{
return (TmpB*) new char[Size];
}
//the first one, this will only be called in case there is a exception in
the constructor
void operator delete(void* Buffer, void* tag)
{
}
//and the second one, this will be called when you delete the instance
void operator delete(void* Buffer)
{
}
Still, one more question, why if the delete operator has adi