The method for dynamically allocating memory is to use the new operator. This operator can be overloaded. To distinguish between the default operator and an overloaded version, the default is called “new operator” and the overloaded version is called “operator new”
The new operator calls a function to perform the requisite memory allocation, and you can rewrite or overload that function to change its behavior. The name of the function the new operator calls to allocate memory is operator new.
The new operator: C++ supports dynamic allocation of objects using the new operator. The new operator allocate memory for objects from a pool called the free store. The new operator calls the special function operator new.
operator new: If the request is for zero bytes of storage, operator new returns a pointer to a distinct object (that is, repeated calls to operator new return different pointers). If there is insufficient memory for the allocation request, operator new returns NULL or throws an exception. The first argument to operator new must be of type size_t (a type defined in STDDEF.H), and the return type is always void *.
The new operator calls a function to perform the requisite memory allocation, and you can rewrite or overload that function to change its behavior. The name of the function the new operator calls to allocate memory is operator new.
The new operator: C++ supports dynamic allocation of objects using the new operator. The new operator allocate memory for objects from a pool called the free store. The new operator calls the special function operator new.
operator new: If the request is for zero bytes of storage, operator new returns a pointer to a distinct object (that is, repeated calls to operator new return different pointers). If there is insufficient memory for the allocation request, operator new returns NULL or throws an exception. The first argument to operator new must be of type size_t (a type defined in STDDEF.H), and the return type is always void *.
No comments:
Post a Comment