Operator New & New operator

Source: Internet
Author: User

Web materials:

Operator new

(1) only allocate the required space and do not call the constructor of the object. When the requested space cannot be met

-> If new_handler exists, new_handler is called. Otherwise

-> If no exception is required (expressed as the nothrow parameter), run the bad_alloc command. Otherwise

-> 0 is returned.

(2) It can be reloaded.

(3) During overload, the return type must be declared as void *

(4) During heavy load, the first parameter type must be the size (in bytes) required for space allocation for the expression, and the type is size_t

(5) You can include other parameters during heavy load.

New operator (in general use of new)

(1) 1. Call operator new to allocate enough space

2. Call the constructor of the relevant object (the constructor can also be parsed here without releasing the memory !)

(2) cannot be overloaded

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.