NEW has six overload forms

xiaoxiao2021-03-06  38

When writing P = new p (); this time, there is actually two steps, first assigning memory, then initializing the class members above allocated memory.

The second step is to have the constructor is completed, the first step is the work of the New function.

The global New has six heavy-duty form, void * operator new (std :: size_t count) throw (std :: bad_alloc); // General Version

Void * operator new (std :: size_t count, // is compatible with early version of New const st :: nothrow_t &) throw (); // Memory allocation failure will not throw an exception

Void * Operator new (std :: size_t count, void * ptr) throw (); // placement version void * operator new [] (std :: size_t count) // throw (std :: bad_alloc);

Void * Operator new [] (std :: size_t count, // const st :: nothrow_t &);

Void * Operator new [] (std :: size_t count, void * ptr) throw ();

转载请注明原文地址:https://www.9cbs.com/read-69333.html

New Post(0)