Re: True/False: As of VC 6.0, with MS compilers, usage of new(noth
ultranet <ultranet@discussions.microsoft.com> wrote:
"Igor Tandetnik" wrote:
Quote the full error message. Error C2665 usually lists the overloads
that were considered by the compiler.
Nope, that's it.
Does MyClass have a class-specific operator new, by any chance?
Bingo, it's a CDialog subclass, and CObject overrides new. I'm not
sure i want to mess w/ adding an operator to my class though.
At the same time, ::new(nothrow) produces a warning, based on what
i've mentioned before:
MyClass.cpp(78) : warning C4291: 'void *__cdecl operator new(unsigned
int,const struct std::nothrow_t &)' : no matching operator delete
found; memory will not be freed if initializa
tion throws an exception
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\new(36)
: see declaration of 'new'
I'm thinking about adding a pragma to ignore the warning maybe, but
probably will just take a note, and use try-catch for these kinds of
classes.
If I recall correctly, in VC6 operator new does not throw bad_alloc
anyway, but always returns NULL when memory allocation fails. So I
suspect the whole issue is moot. You can test it with something like
char* p = new char[0x7FFFFFFF];
and see if you get an exception, or a NULL pointer.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925