Udostępnij za pośrednictwem


new and delete Operators

C++ supports dynamic allocation and deallocation of objects using the new and delete operators. These operators allocate memory for objects from a pool called the free store. The new operator calls the special function operator new, and the delete operator calls the special function operator delete.

In Visual C++ .NET 2002, the new function in the Standard C++ Library will support the behavior specified in the C++ standard, which is to throw a std::bad_alloc exception if the memory allocation fails.

The C Runtime Library's new function will also throw a std::bad_alloc exception if the memory allocation fails.

If you still want the non-throwing version of new for the C Runtime Library, link your program with nothrownew.obj. However, when you link with nothrownew.obj, new in the Standard C++ Library will no longer function.

For a list of the library files that comprise the C Runtime Library and the Standard C++ Library, see C Run-Time Libraries.

See Also

Reference

Special Member Functions