Kommentar
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Native C++ classes support dynamic allocation and deallocation of objects by providing 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.
The new function in the Standard C++ Library supports the behavior specified in the C++ standard and throws a std::bad_alloc exception if memory allocation fails.
The C Runtime Library's new function throws a std::bad_alloc exception if memory allocation fails.
If you want to use the non-throwing version of new for the C Runtime Library, link your program together 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 contain the C Runtime Library and the Standard C++ Library, see C Run-Time Libraries.
Managed C++ classes provide the gcnew operator instead of new and delete. For more information, see Language Features for Targeting the CLR. Managed C++ supports automatic garbage collection.