new is a language construct that dynamically allocates memory from free store and initialises the memory using the constructor.
Use this tag in conjunction with a language specific tag.
The new operator in C++
The C++ standard library provides several overloads of operator new
and it can also be overloaded for your own classes.
Use this tag for questions about dynamic allocation in C++ and questions about overloading operator new
. The placement-new tag may also be relevant for questions about constructing objects in existing memory.
Memory allocated with new
must be de-allocated using delete
C++ operator.
The new operator in other languages
The new
operator is used in several other languages as well, including C#, Java, Javascript, and Perl. Use this tag for questions about memory allocation and instantiating objects in those languages.
Some highlighted questions about new-operator
- Why should C++ programmers minimize use of 'new'?
- Do the parentheses after the type name make a difference with new?
- Passing arguments to C# generic new() of templated type
- Using "Object.create" instead of "new"
- Why does the use of 'new' cause memory leaks?
- C++ new int[0] -- will it allocate memory?
- Why would one replace default new and delete operators?