<s>
In	O
the	O
C++	B-Language
programming	I-Language
language	I-Language
,	O
and	O
are	O
a	O
pair	O
of	O
language	O
constructs	O
that	O
perform	O
dynamic	B-General_Concept
memory	I-General_Concept
allocation	I-General_Concept
,	O
object	O
construction	O
and	O
object	O
destruction	O
.	O
</s>
<s>
Except	O
for	O
a	O
form	O
called	O
the	O
"	B-Language
placement	I-Language
new	I-Language
"	I-Language
,	O
the	O
operator	O
denotes	O
a	O
request	O
for	O
memory	B-General_Concept
allocation	I-General_Concept
on	O
a	O
process	O
's	O
heap	O
.	O
</s>
<s>
If	O
not	B-General_Concept
enough	I-General_Concept
memory	I-General_Concept
is	O
available	O
in	O
the	O
free	O
store	O
for	O
an	O
object	O
of	O
type	O
,	O
the	O
request	O
indicates	O
failure	O
by	O
throwing	O
an	O
exception	B-General_Concept
of	O
type	O
.	O
</s>
<s>
The	O
deallocation	B-General_Concept
counterpart	O
of	O
is	O
,	O
which	O
first	O
calls	O
the	O
destructor	O
(	O
if	O
any	O
)	O
on	O
its	O
argument	O
and	O
then	O
returns	O
the	O
memory	O
allocated	O
by	O
back	O
to	O
the	O
free	O
store	O
.	O
</s>
<s>
Every	O
call	O
to	O
must	O
be	O
matched	O
by	O
a	O
call	O
to	O
;	O
failure	O
to	O
do	O
so	O
causes	O
a	O
memory	B-Error_Name
leak	I-Error_Name
.	O
</s>
<s>
syntax	O
has	O
several	O
variants	O
that	O
allow	O
finer	O
control	O
over	O
memory	B-General_Concept
allocation	I-General_Concept
and	O
object	O
construction	O
.	O
</s>
<s>
A	O
different	O
variant	O
allocates	O
and	O
initialises	O
arrays	B-Data_Structure
of	O
objects	O
rather	O
than	O
single	O
objects	O
:	O
</s>
<s>
Using	O
the	O
inappropriate	O
form	O
results	O
in	O
undefined	B-Language
behavior	I-Language
.	O
</s>
<s>
C++	B-Language
compilers	O
are	O
not	O
required	O
to	O
generate	O
a	O
diagnostic	O
message	O
for	O
using	O
the	O
wrong	O
form	O
.	O
</s>
<s>
The	O
C++11	B-Language
standard	O
specifies	O
an	O
additional	O
syntax	O
,	O
</s>
<s>
Firstly	O
,	O
the	O
ISO	O
C++	B-Language
standard	O
allows	O
programs	O
to	O
register	O
a	O
custom	O
function	O
called	O
a	O
with	O
the	O
C++	B-Language
runtime	B-Library
;	O
if	O
it	O
does	O
,	O
then	O
this	O
function	O
is	O
called	O
whenever	O
encounters	O
an	O
error	O
.	O
</s>
<s>
If	O
no	O
is	O
installed	O
,	O
instead	O
throws	O
an	O
exception	B-General_Concept
of	O
type	O
.	O
</s>
<s>
Thus	O
,	O
the	O
program	O
does	O
not	O
need	O
to	O
check	O
the	O
value	O
of	O
the	O
returned	O
pointer	O
,	O
as	O
is	O
the	O
habit	O
in	O
C	B-Language
;	O
if	O
no	O
exception	B-General_Concept
was	O
thrown	O
,	O
the	O
allocation	O
succeeded	O
.	O
</s>
<s>
The	O
third	O
method	O
of	O
error	B-General_Concept
handling	I-General_Concept
is	O
provided	O
by	O
the	O
variant	O
form	O
,	O
which	O
specifies	O
that	O
no	O
exception	B-General_Concept
should	O
be	O
thrown	O
;	O
instead	O
,	O
a	O
null	O
pointer	O
is	O
returned	O
to	O
signal	O
an	O
allocation	O
error	O
.	O
</s>
<s>
The	O
operator	O
can	O
be	O
overloaded	O
so	O
that	O
specific	O
types	O
(	O
classes	O
)	O
use	O
custom	O
memory	B-General_Concept
allocation	I-General_Concept
algorithms	O
for	O
their	O
instances	O
.	O
</s>
<s>
This	O
feature	O
was	O
available	O
from	O
early	O
on	O
in	O
C++'s	O
history	O
,	O
although	O
the	O
specific	O
overloading	O
mechanism	O
changed	O
.	O
</s>
<s>
It	O
was	O
added	O
to	O
the	O
language	O
because	O
object-oriented	B-Language
C++	B-Language
programs	I-Language
tended	O
to	O
allocate	O
many	O
small	O
objects	O
with	O
,	O
which	O
internally	O
used	O
the	O
C	B-Language
allocator	B-Application
(	O
see	O
)	O
;	O
that	O
,	O
however	O
,	O
was	O
optimized	O
for	O
the	O
fewer	O
and	O
larger	O
allocations	O
performed	O
by	O
typical	O
C	B-Language
programs	O
.	O
</s>
<s>
Stroustrup	O
reported	O
that	O
in	O
early	O
applications	O
,	O
the	O
C	B-Language
function	O
was	O
"	O
the	O
most	O
common	O
performance	O
bottleneck	O
in	O
real	O
systems	O
"	O
,	O
with	O
programs	O
spending	O
up	O
to	O
50%	O
of	O
their	O
time	O
in	O
this	O
function	O
.	O
</s>
<s>
Since	O
standard	O
C++	B-Language
subsumes	O
the	B-Language
C	I-Language
standard	I-Language
library	I-Language
,	O
the	O
C	B-Language
dynamic	I-Language
memory	I-Language
allocation	I-Language
routines	O
,	O
,	O
and	O
are	O
also	O
available	O
to	O
C++	B-Language
programmers	O
.	O
</s>
<s>
and	O
were	O
,	O
in	O
fact	O
,	O
introduced	O
in	O
the	O
first	O
version	O
of	O
C++	B-Language
(	O
then	O
called	O
"	O
C	B-Language
with	O
Classes	O
"	O
)	O
to	O
avoid	O
the	O
necessity	O
of	O
manual	O
object	O
initialization	O
.	O
</s>
<s>
In	O
contrast	O
to	O
the	O
C	B-Language
routines	O
,	O
which	O
allow	O
growing	O
or	O
shrinking	O
an	O
allocated	O
array	O
with	O
,	O
it	O
is	O
not	O
possible	O
to	O
change	O
the	O
size	O
of	O
a	O
memory	O
buffer	O
allocated	O
by	O
.	O
</s>
<s>
The	O
C++	B-Language
standard	I-Language
library	I-Language
instead	O
provides	O
a	O
dynamic	B-Data_Structure
array	I-Data_Structure
(	O
collection	O
)	O
that	O
can	O
be	O
extended	O
or	O
reduced	O
in	O
its	O
template	O
class	O
.	O
</s>
<s>
The	O
C++	B-Language
standard	O
does	O
not	O
specify	O
any	O
relation	O
between	O
/	O
and	O
the	O
C	B-Language
memory	B-General_Concept
allocation	I-General_Concept
routines	O
,	O
but	O
and	O
are	O
typically	O
implemented	O
as	O
wrappers	O
around	O
and	O
.	O
</s>
<s>
Mixing	O
the	O
two	O
families	O
of	O
operations	O
,	O
e.g.	O
,	O
'	O
ing	O
'	O
ly	O
allocated	O
memory	O
or	O
'	O
ing	O
'	O
d	O
memory	O
,	O
causes	O
undefined	B-Language
behavior	I-Language
and	O
in	O
practice	O
can	O
lead	O
to	O
various	O
catastrophic	O
results	O
such	O
as	O
failure	O
to	O
release	O
locks	B-Operating_System
and	O
thus	O
deadlock	B-Operating_System
.	O
</s>
