What is the new operator?
The keyword new is used to dynamically allocate memory in C++. There are two forms for new. One allocates space for a single object in memory and initializes that object to a specified value. The second allocates a block of memory large enough to store a specified number of objects.‘New’ returns the address of the start of the allocated memory. This is typically stored in a pointer. When an object is created with the new operator, its constructor is called implicitly. Any object created with new operator must be destroyed using the ‘delete’ operator.
Some examples of the new operator:
class foo { /* ... */ };
void
f ()
{
foo *foop = new foo;
char * str = new char[20];
int * p = new int (7);
// ...
delete p;
delete[] str;
delete foo;
}
C++ FAQ Home
Sponsored links
Software Localization Tool Sisulizer
Localize DotNet, C++ Builder, Delphi, C/C++, Visual Basic & Java apps & html help. Try Sisulizer now
Localize DotNet, C++ Builder, Delphi, C/C++, Visual Basic & Java apps & html help. Try Sisulizer now
CSTSOFT Instrumentation .NET & ActiveX Components
A collection of 13 instrumentation .NET/ActiveX/VCL components including Gauge,Knob,LED,Trend etc.
A collection of 13 instrumentation .NET/ActiveX/VCL components including Gauge,Knob,LED,Trend etc.
Web based bug tracking - AdminiTrack.com
AdminiTrack offers an effective web-based bug tracking system designed for professional software development teams.
AdminiTrack offers an effective web-based bug tracking system designed for professional software development teams.
DVD/CD Duplicators - All Free Shipping
Simple Disc-to-Disc Duplication. 2 Year Warranty & Free Shipping.
Simple Disc-to-Disc Duplication. 2 Year Warranty & Free Shipping.
-software
-software, Try 4 Different Flavors Today, Pay Only Shipping Fee.
-software, Try 4 Different Flavors Today, Pay Only Shipping Fee.
