<s>
C++	B-Language
(	O
,	O
pronounced	O
"	O
C	B-Language
plus	I-Language
plus	I-Language
"	O
)	O
is	O
a	O
high-level	B-Language
,	O
general-purpose	B-Language
programming	I-Language
language	I-Language
created	O
by	O
Danish	O
computer	O
scientist	O
Bjarne	O
Stroustrup	O
.	O
</s>
<s>
First	O
released	O
in	O
1985	O
as	O
an	O
extension	O
of	O
the	O
C	B-Language
programming	I-Language
language	I-Language
,	O
it	O
has	O
since	O
expanded	O
significantly	O
over	O
time	O
;	O
modern	O
C++	B-Language
currently	O
has	O
object-oriented	B-Language
,	O
generic	B-Language
,	O
and	O
functional	B-Language
features	O
,	O
in	O
addition	O
to	O
facilities	O
for	O
low-level	B-Language
memory	B-General_Concept
manipulation	O
.	O
</s>
<s>
It	O
is	O
almost	O
always	O
implemented	O
as	O
a	O
compiled	B-Language
language	I-Language
,	O
and	O
many	O
vendors	O
provide	O
C++	B-Language
compilers	B-Language
,	O
including	O
the	B-Operating_System
Free	I-Operating_System
Software	I-Operating_System
Foundation	I-Operating_System
,	O
LLVM	B-Application
,	O
Microsoft	O
,	O
Intel	O
,	O
Embarcadero	O
,	O
Oracle	B-Application
,	O
and	O
IBM	O
.	O
</s>
<s>
C++	B-Language
was	O
designed	O
with	O
systems	B-Application
programming	I-Application
and	O
embedded	B-Application
,	O
resource-constrained	O
software	O
and	O
large	O
systems	O
in	O
mind	O
,	O
with	O
performance	O
,	O
efficiency	O
,	O
and	O
flexibility	O
of	O
use	O
as	O
its	O
design	O
highlights	O
.	O
</s>
<s>
C++	B-Language
has	O
also	O
been	O
found	O
useful	O
in	O
many	O
other	O
contexts	O
,	O
with	O
key	O
strengths	O
being	O
software	O
infrastructure	O
and	O
resource-constrained	O
applications	O
,	O
including	O
desktop	B-Application
applications	I-Application
,	O
video	O
games	O
,	O
servers	B-Application
(	O
e.g.	O
</s>
<s>
e-commerce	O
,	O
web	B-Application
search	I-Application
,	O
or	O
databases	O
)	O
,	O
and	O
performance-critical	O
applications	O
(	O
e.g.	O
</s>
<s>
C++	B-Language
is	O
standardized	O
by	O
the	O
International	O
Organization	O
for	O
Standardization	O
(	O
ISO	O
)	O
,	O
with	O
the	O
latest	O
standard	O
version	O
ratified	O
and	O
published	O
by	O
ISO	O
in	O
December	O
2020	O
as	O
ISO/IEC	O
14882:2020	O
(	O
informally	O
known	O
as	O
C++20	B-Language
)	O
.	O
</s>
<s>
The	O
C++	B-Language
programming	I-Language
language	I-Language
was	O
initially	O
standardized	O
in	O
1998	O
as	O
ISO/IEC	O
14882:1998	O
,	O
which	O
was	O
then	O
amended	O
by	O
the	O
C++03	B-Language
,	O
C++11	B-Language
,	O
C++14	B-Language
,	O
and	O
C++17	B-Language
standards	O
.	O
</s>
<s>
The	O
current	O
C++20	B-Language
standard	O
supersedes	O
these	O
with	O
new	O
features	O
and	O
an	O
enlarged	O
standard	B-Library
library	I-Library
.	O
</s>
<s>
Before	O
the	O
initial	O
standardization	O
in	O
1998	O
,	O
C++	B-Language
was	O
developed	O
by	O
Stroustrup	O
at	O
Bell	O
Labs	O
since	O
1979	O
as	O
an	O
extension	O
of	O
the	O
C	B-Language
language	I-Language
;	O
he	O
wanted	O
an	O
efficient	O
and	O
flexible	O
language	O
similar	O
to	O
C	B-Language
that	O
also	O
provided	O
high-level	B-Language
features	I-Language
for	O
program	O
organization	O
.	O
</s>
<s>
Since	O
2012	O
,	O
C++	B-Language
has	O
been	O
on	O
a	O
three-year	O
release	O
schedule	O
with	O
C++23	B-Language
as	O
the	O
next	O
planned	O
standard	O
.	O
</s>
<s>
In	O
1979	O
,	O
Bjarne	O
Stroustrup	O
,	O
a	O
Danish	O
computer	O
scientist	O
,	O
began	O
work	O
on	O
""	O
,	O
the	O
predecessor	O
to	O
C++	B-Language
.	O
</s>
<s>
Stroustrup	O
found	O
that	O
Simula	B-Language
had	O
features	O
that	O
were	O
very	O
helpful	O
for	O
large	O
software	O
development	O
,	O
but	O
the	O
language	O
was	O
too	O
slow	O
for	O
practical	O
use	O
,	O
while	O
BCPL	B-Language
was	O
fast	O
but	O
too	O
low-level	B-Language
to	O
be	O
suitable	O
for	O
large	O
software	O
development	O
.	O
</s>
<s>
When	O
Stroustrup	O
started	O
working	O
in	O
AT&T	O
Bell	O
Labs	O
,	O
he	O
had	O
the	O
problem	O
of	O
analyzing	O
the	O
UNIX	B-Application
kernel	B-Operating_System
with	O
respect	O
to	O
distributed	B-Architecture
computing	I-Architecture
.	O
</s>
<s>
Remembering	O
his	O
PhD	O
experience	O
,	O
Stroustrup	O
set	O
out	O
to	O
enhance	O
the	O
C	B-Language
language	I-Language
with	O
Simula-like	O
features	O
.	O
</s>
<s>
C	B-Language
was	O
chosen	O
because	O
it	O
was	O
general-purpose	B-Language
,	O
fast	O
,	O
portable	O
and	O
widely	O
used	O
.	O
</s>
<s>
As	O
well	O
as	O
C	B-Language
and	O
Simula	B-Language
's	O
influences	O
,	O
other	O
languages	O
also	O
influenced	O
this	O
new	O
language	O
,	O
including	O
ALGOL	B-Language
68	I-Language
,	O
Ada	B-Language
,	O
CLU	B-Language
and	O
ML	B-Language
.	O
</s>
<s>
Initially	O
,	O
Stroustrup	O
's	O
"	O
C	B-Language
with	O
Classes	O
"	O
added	O
features	O
to	O
the	O
C	B-Language
compiler	B-Language
,	O
Cpre	O
,	O
including	O
classes	O
,	O
derived	O
classes	O
,	O
strong	O
typing	O
,	O
inlining	O
and	O
default	B-Language
arguments	I-Language
.	O
</s>
<s>
In	O
1982	O
,	O
Stroustrup	O
started	O
to	O
develop	O
a	O
successor	O
to	O
C	B-Language
with	O
Classes	O
,	O
which	O
he	O
named	O
"	O
C++	B-Language
"	O
(	O
being	O
the	O
increment	O
operator	O
in	O
C	B-Language
)	O
after	O
going	O
through	O
several	O
other	O
names	O
.	O
</s>
<s>
New	O
features	O
were	O
added	O
,	O
including	O
virtual	B-Application
functions	I-Application
,	O
function	O
name	O
and	O
operator	O
overloading	B-Application
,	O
references	O
,	O
constants	O
,	O
type-safe	O
free-store	O
memory	B-General_Concept
allocation	I-General_Concept
(	O
new/delete	O
)	O
,	O
improved	O
type	O
checking	O
,	O
and	O
BCPL	B-Language
style	O
single-line	O
comments	O
with	O
two	O
forward	O
slashes	O
(	O
)	O
.	O
</s>
<s>
Furthermore	O
,	O
Stroustrup	O
developed	O
a	O
new	O
,	O
standalone	O
compiler	B-Language
for	O
C++	B-Language
,	O
Cfront	B-Device
.	O
</s>
<s>
In	O
1984	O
,	O
Stroustrup	O
implemented	O
the	O
first	O
stream	O
input/output	O
library	B-Library
.	O
</s>
<s>
The	O
idea	O
of	O
providing	O
an	O
output	O
operator	O
rather	O
than	O
a	O
named	O
output	O
function	O
was	O
suggested	O
by	O
Doug	O
McIlroy	O
(	O
who	O
had	O
previously	O
suggested	O
Unix	B-Operating_System
pipes	I-Operating_System
)	O
.	O
</s>
<s>
In	O
1985	O
,	O
the	O
first	O
edition	O
of	O
The	O
C++	B-Language
Programming	I-Language
Language	I-Language
was	O
released	O
,	O
which	O
became	O
the	O
definitive	O
reference	B-Language
for	O
the	O
language	O
,	O
as	O
there	O
was	O
not	O
yet	O
an	O
official	O
standard	O
.	O
</s>
<s>
The	O
first	O
commercial	O
implementation	O
of	O
C++	B-Language
was	O
released	O
in	O
October	O
of	O
the	O
same	O
year	O
.	O
</s>
<s>
In	O
1989	O
,	O
C++	B-Language
2.0	O
was	O
released	O
,	O
followed	O
by	O
the	O
updated	O
second	O
edition	O
of	O
The	O
C++	B-Language
Programming	I-Language
Language	I-Language
in	O
1991	O
.	O
</s>
<s>
New	O
features	O
in	O
2.0	O
included	O
multiple	B-Application
inheritance	I-Application
,	O
abstract	O
classes	O
,	O
static	O
member	O
functions	O
,	O
const	O
member	O
functions	O
,	O
and	O
protected	O
members	O
.	O
</s>
<s>
In	O
1990	O
,	O
The	O
Annotated	O
C++	B-Language
Reference	I-Language
Manual	O
was	O
published	O
.	O
</s>
<s>
Later	O
feature	B-Architecture
additions	O
included	O
templates	B-Application
,	O
exceptions	B-General_Concept
,	O
namespaces	O
,	O
new	O
casts	O
,	O
and	O
a	O
Boolean	O
type	O
.	O
</s>
<s>
In	O
1998	O
,	O
C++98	O
was	O
released	O
,	O
standardizing	O
the	O
language	O
,	O
and	O
a	O
minor	O
update	O
(	O
C++03	B-Language
)	O
was	O
released	O
in	O
2003	O
.	O
</s>
<s>
After	O
C++98	O
,	O
C++	B-Language
evolved	O
relatively	O
slowly	O
until	O
,	O
in	O
2011	O
,	O
the	O
C++11	B-Language
standard	O
was	O
released	O
,	O
adding	O
numerous	O
new	O
features	O
,	O
enlarging	O
the	O
standard	B-Library
library	I-Library
further	O
,	O
and	O
providing	O
more	O
facilities	O
to	O
C++	B-Language
programmers	O
.	O
</s>
<s>
After	O
a	O
minor	O
C++14	B-Language
update	O
released	O
in	O
December	O
2014	O
,	O
various	O
new	O
additions	O
were	O
introduced	O
in	O
C++17	B-Language
.	O
</s>
<s>
After	O
becoming	O
finalized	O
in	O
February	O
2020	O
,	O
a	O
draft	O
of	O
the	O
C++20	B-Language
standard	O
was	O
approved	O
on	O
4	O
September	O
2020	O
and	O
officially	O
published	O
on	O
15	O
December	O
2020	O
.	O
</s>
<s>
On	O
January	O
3	O
,	O
2018	O
,	O
Stroustrup	O
was	O
announced	O
as	O
the	O
2018	O
winner	O
of	O
the	O
Charles	O
Stark	O
Draper	O
Prize	O
for	O
Engineering	O
,	O
"	O
for	O
conceptualizing	O
and	O
developing	O
the	O
C++	B-Language
programming	I-Language
language	I-Language
"	O
.	O
</s>
<s>
C++	B-Language
ranked	O
third	O
on	O
the	O
TIOBE	O
index	O
,	O
surpassing	O
Java	B-Language
for	O
the	O
first	O
time	O
in	O
the	O
history	O
of	O
the	O
index	O
.	O
</s>
<s>
It	O
ranks	O
3rd	O
,	O
after	O
Python	B-Language
and	O
C	B-Language
.	O
</s>
<s>
According	O
to	O
Stroustrup	O
,	O
"	O
the	O
name	O
signifies	O
the	O
evolutionary	O
nature	O
of	O
the	O
changes	O
from	O
C	B-Language
"	O
.	O
</s>
<s>
The	O
name	O
comes	O
from	O
C	B-Language
's	O
operator	O
(	O
which	O
increments	O
the	O
value	O
of	O
a	O
variable	O
)	O
and	O
a	O
common	O
naming	O
convention	O
of	O
using	O
"	O
+	O
"	O
to	O
indicate	O
an	O
enhanced	O
computer	O
program	O
.	O
</s>
<s>
During	O
C++'s	O
development	O
period	O
,	O
the	O
language	O
had	O
been	O
referred	O
to	O
as	O
"	O
new	O
C	B-Language
"	O
and	O
"	O
C	B-Language
with	O
Classes	O
"	O
before	O
acquiring	O
its	O
final	O
name	O
.	O
</s>
<s>
Throughout	O
C++'s	O
life	O
,	O
its	O
development	O
and	O
evolution	O
has	O
been	O
guided	O
by	O
a	O
set	O
of	O
principles	O
:	O
</s>
<s>
Every	O
feature	B-Architecture
should	O
be	O
implementable	O
(	O
with	O
a	O
reasonably	O
obvious	O
way	O
to	O
do	O
so	O
)	O
.	O
</s>
<s>
Programmers	O
should	O
be	O
free	O
to	O
pick	O
their	O
own	O
programming	O
style	O
,	O
and	O
that	O
style	O
should	O
be	O
fully	O
supported	O
by	O
C++	B-Language
.	O
</s>
<s>
Allowing	O
a	O
useful	O
feature	B-Architecture
is	O
more	O
important	O
than	O
preventing	O
every	O
possible	O
misuse	O
of	O
C++	B-Language
.	O
</s>
<s>
There	O
should	O
be	O
no	O
language	O
beneath	O
C++	B-Language
(	O
except	O
assembly	B-Language
language	I-Language
)	O
.	O
</s>
<s>
C++	B-Language
should	O
work	O
alongside	O
other	O
existing	O
programming	O
languages	O
,	O
rather	O
than	O
fostering	O
its	O
own	O
separate	O
and	O
incompatible	O
programming	B-Application
environment	I-Application
.	O
</s>
<s>
C++	B-Language
is	O
standardized	O
by	O
an	O
ISO	O
working	O
group	O
known	O
as	O
JTC1/SC22/WG21	O
.	O
</s>
<s>
So	O
far	O
,	O
it	O
has	O
published	O
six	O
revisions	O
of	O
the	O
C++	B-Language
standard	O
and	O
is	O
currently	O
working	O
on	O
the	O
next	O
revision	O
,	O
C++23	B-Language
.	O
</s>
<s>
In	O
1998	O
,	O
the	O
ISO	O
working	O
group	O
standardized	O
C++	B-Language
for	O
the	O
first	O
time	O
as	O
ISO/IEC	O
14882:1998	O
,	O
which	O
is	O
informally	O
known	O
as	O
C++98	O
.	O
</s>
<s>
In	O
2003	O
,	O
it	O
published	O
a	O
new	O
version	O
of	O
the	O
C++	B-Language
standard	O
called	O
ISO/IEC	O
14882:2003	O
,	O
which	O
fixed	O
problems	O
identified	O
in	O
C++98	O
.	O
</s>
<s>
The	O
next	O
major	O
revision	O
of	O
the	O
standard	O
was	O
informally	O
referred	O
to	O
as	O
"	O
C++0x	B-Language
"	O
,	O
but	O
it	O
was	O
not	O
released	O
until	O
2011	O
.	O
</s>
<s>
C++11	B-Language
(	O
14882:2011	O
)	O
included	O
many	O
additions	O
to	O
both	O
the	O
core	O
language	O
and	O
the	O
standard	B-Library
library	I-Library
.	O
</s>
<s>
In	O
2014	O
,	O
C++14	B-Language
(	O
also	O
known	O
as	O
C++1y	B-Language
)	O
was	O
released	O
as	O
a	O
small	O
extension	O
to	O
C++11	B-Language
,	O
featuring	O
mainly	O
bug	O
fixes	O
and	O
small	O
improvements	O
.	O
</s>
<s>
After	O
C++14	B-Language
,	O
a	O
major	O
revision	O
C++17	B-Language
,	O
informally	O
known	O
as	O
C++1z	B-Language
,	O
was	O
completed	O
by	O
the	O
ISO	O
C++	B-Language
committee	O
in	O
mid	O
July	O
2017	O
and	O
was	O
approved	O
and	O
published	O
in	O
December	O
2017	O
.	O
</s>
<s>
ISO/IEC	O
TR	O
18015:2006	O
on	O
the	O
use	O
of	O
C++	B-Language
in	O
embedded	B-Application
systems	O
and	O
on	O
performance	O
implications	O
of	O
C++	B-Language
language	I-Language
and	O
library	B-Library
features	O
,	O
</s>
<s>
ISO/IEC	O
TR	O
19768:2007	O
(	O
also	O
known	O
as	O
the	O
C++	B-Language
Technical	I-Language
Report	I-Language
1	I-Language
)	O
on	O
library	B-Library
extensions	O
mostly	O
integrated	O
into	O
C++11	B-Language
,	O
</s>
<s>
ISO/IEC	O
TS	O
19841:2015	O
on	O
software	O
transactional	B-Operating_System
memory	I-Operating_System
,	O
</s>
<s>
ISO/IEC	O
TS	O
19568:2015	O
on	O
a	O
new	O
set	O
of	O
library	B-Library
extensions	O
,	O
some	O
of	O
which	O
are	O
already	O
integrated	O
into	O
C++17	B-Language
,	O
</s>
<s>
The	O
C++	B-Language
language	I-Language
has	O
two	O
main	O
components	O
:	O
a	O
direct	O
mapping	O
of	O
hardware	O
features	O
provided	O
primarily	O
by	O
the	O
C	B-Language
subset	O
,	O
and	O
zero-overhead	O
abstractions	B-Application
based	O
on	O
those	O
mappings	O
.	O
</s>
<s>
Stroustrup	O
describes	O
C++	B-Language
as	O
"	O
a	O
light-weight	O
abstraction	B-Application
programming	O
language	O
 [ designed ] 	O
for	O
building	O
and	O
using	O
efficient	O
and	O
elegant	O
abstractions	B-Application
"	O
;	O
and	O
"	O
offering	O
both	O
hardware	O
access	O
and	O
abstraction	B-Application
is	O
the	O
basis	O
of	O
C++	B-Language
.	O
</s>
<s>
C++	B-Language
inherits	O
most	O
of	O
C	B-Language
's	O
syntax	O
.	O
</s>
<s>
The	O
following	O
is	O
Bjarne	O
Stroustrup	O
's	O
version	O
of	O
the	O
Hello	O
world	O
program	O
that	O
uses	O
the	O
C++	B-Language
Standard	I-Language
Library	I-Language
stream	O
facility	O
to	O
write	O
a	O
message	O
to	O
standard	O
output	O
:	O
</s>
<s>
As	O
in	O
C	B-Language
,	O
C++	B-Language
supports	O
four	O
types	O
of	O
memory	B-General_Concept
management	I-General_Concept
:	O
static	O
storage	O
duration	O
objects	O
,	O
thread	B-Operating_System
storage	O
duration	O
objects	O
,	O
automatic	O
storage	O
duration	O
objects	O
,	O
and	O
dynamic	B-General_Concept
storage	I-General_Concept
duration	O
objects	O
.	O
</s>
<s>
Static	O
storage	O
duration	O
objects	O
are	O
created	O
before	O
main( )	O
is	O
entered	O
(	O
see	O
exceptions	B-General_Concept
below	O
)	O
and	O
destroyed	O
in	O
reverse	O
order	O
of	O
creation	O
after	O
main( )	O
exits	O
.	O
</s>
<s>
Though	O
it	O
is	O
not	O
specified	O
in	O
the	O
standard	O
,	O
the	O
static	O
initialization	O
phase	O
can	O
be	O
completed	O
at	O
compile	B-Application
time	I-Application
and	O
saved	O
in	O
the	O
data	O
partition	O
of	O
the	O
executable	O
.	O
</s>
<s>
Dynamic	O
initialization	O
involves	O
all	O
object	O
initialization	O
done	O
via	O
a	O
constructor	O
or	O
function	O
call	O
(	O
unless	O
the	O
function	O
is	O
marked	O
with	O
constexpr	O
,	O
in	O
C++11	B-Language
)	O
.	O
</s>
<s>
The	O
dynamic	O
initialization	O
order	O
is	O
defined	O
as	O
the	O
order	O
of	O
declaration	O
within	O
the	O
compilation	B-Language
unit	O
(	O
i.e.	O
</s>
<s>
No	O
guarantees	O
are	O
provided	O
about	O
the	O
order	O
of	O
initialization	O
between	O
compilation	B-Language
units	O
.	O
</s>
<s>
The	O
main	O
difference	O
is	O
the	O
creation	O
time	O
is	O
just	O
prior	O
to	O
thread	B-Operating_System
creation	O
and	O
destruction	O
is	O
done	O
after	O
the	O
thread	B-Operating_System
has	O
been	O
joined	O
.	O
</s>
<s>
The	O
most	O
common	O
variable	O
types	O
in	O
C++	B-Language
are	O
local	O
variables	O
inside	O
a	O
function	O
or	O
block	O
,	O
and	O
temporary	O
variables	O
.	O
</s>
<s>
The	O
common	O
feature	B-Architecture
about	O
automatic	O
variables	O
is	O
that	O
they	O
have	O
a	O
lifetime	O
that	O
is	O
limited	O
to	O
the	O
scope	O
of	O
the	O
variable	O
.	O
</s>
<s>
This	O
is	O
implemented	O
by	O
allocation	O
on	O
the	O
stack	B-General_Concept
.	O
</s>
<s>
C++	B-Language
destructors	B-Language
for	O
local	O
variables	O
are	O
called	O
at	O
the	O
end	O
of	O
the	O
object	O
lifetime	O
,	O
allowing	O
a	O
discipline	O
for	O
automatic	O
resource	O
management	O
termed	O
RAII	B-Application
,	O
which	O
is	O
widely	O
used	O
in	O
C++	B-Language
.	O
</s>
<s>
C++	B-Language
also	O
supports	O
malloc	O
and	O
free	O
,	O
from	O
C	B-Language
,	O
but	O
these	O
are	O
not	O
compatible	O
with	O
and	O
.	O
</s>
<s>
Use	O
of	O
returns	O
an	O
address	O
to	O
the	O
allocated	O
memory	B-General_Concept
.	O
</s>
<s>
The	O
C++	B-Language
Core	O
Guidelines	O
advise	O
against	O
using	O
directly	O
for	O
creating	O
dynamic	O
objects	O
in	O
favor	O
of	O
smart	B-Language
pointers	I-Language
through	O
for	O
single	O
ownership	O
and	O
for	O
reference-counted	O
multiple	O
ownership	O
,	O
which	O
were	O
introduced	O
in	O
C++11	B-Language
.	I-Language
</s>
<s>
C++	B-Application
templates	I-Application
enable	O
generic	B-Language
programming	I-Language
.	O
</s>
<s>
C++	B-Language
supports	O
function	O
,	O
class	O
,	O
alias	O
,	O
and	O
variable	O
templates	B-Application
.	O
</s>
<s>
Templates	B-Application
may	O
be	O
parameterized	O
by	O
types	O
,	O
compile-time	B-Application
constants	O
,	O
and	O
other	O
templates	B-Application
.	O
</s>
<s>
Templates	B-Application
are	O
implemented	O
by	O
instantiation	O
at	O
compile-time	B-Application
.	O
</s>
<s>
To	O
instantiate	O
a	O
template	B-Application
,	O
compilers	B-Language
substitute	O
specific	O
arguments	O
for	O
a	O
template	B-Application
's	O
parameters	O
to	O
generate	O
a	O
concrete	O
function	O
or	O
class	O
instance	O
.	O
</s>
<s>
Some	O
substitutions	O
are	O
not	O
possible	O
;	O
these	O
are	O
eliminated	O
by	O
an	O
overload	B-Language
resolution	I-Language
policy	O
described	O
by	O
the	O
phrase	O
"	O
Substitution	B-Language
failure	I-Language
is	I-Language
not	I-Language
an	I-Language
error	I-Language
"	O
(	O
SFINAE	B-Language
)	O
.	O
</s>
<s>
Templates	B-Application
are	O
a	O
powerful	O
tool	O
that	O
can	O
be	O
used	O
for	O
generic	B-Language
programming	I-Language
,	O
template	B-Language
metaprogramming	I-Language
,	O
and	O
code	O
optimization	O
,	O
but	O
this	O
power	O
implies	O
a	O
cost	O
.	O
</s>
<s>
Template	B-Application
use	O
may	O
increase	O
code	O
size	O
,	O
because	O
each	O
template	B-Application
instantiation	O
produces	O
a	O
copy	O
of	O
the	O
template	B-Application
code	O
:	O
one	O
for	O
each	O
set	O
of	O
template	B-Application
arguments	O
,	O
however	O
,	O
this	O
is	O
the	O
same	O
or	O
smaller	O
amount	O
of	O
code	O
that	O
would	O
be	O
generated	O
if	O
the	O
code	O
was	O
written	O
by	O
hand	O
.	O
</s>
<s>
This	O
is	O
in	O
contrast	O
to	O
run-time	B-Library
generics	O
seen	O
in	O
other	O
languages	O
(	O
e.g.	O
,	O
Java	B-Language
)	O
where	O
at	O
compile-time	B-Application
the	O
type	O
is	O
erased	O
and	O
a	O
single	O
template	B-Application
body	O
is	O
preserved	O
.	O
</s>
<s>
Templates	B-Application
are	O
different	O
from	O
macros	O
:	O
while	O
both	O
of	O
these	O
compile-time	B-Application
language	O
features	O
enable	O
conditional	O
compilation	B-Language
,	O
templates	B-Application
are	O
not	O
restricted	O
to	O
lexical	O
substitution	O
.	O
</s>
<s>
Templates	B-Application
are	O
aware	O
of	O
the	O
semantics	O
and	O
type	O
system	O
of	O
their	O
companion	O
language	O
,	O
as	O
well	O
as	O
all	O
compile-time	B-Application
type	O
definitions	O
,	O
and	O
can	O
perform	O
high-level	B-Language
operations	O
including	O
programmatic	O
flow	O
control	O
based	O
on	O
evaluation	O
of	O
strictly	O
type-checked	O
parameters	O
.	O
</s>
<s>
Macros	O
are	O
capable	O
of	O
conditional	O
control	O
over	O
compilation	B-Language
based	O
on	O
predetermined	O
criteria	O
,	O
but	O
cannot	O
instantiate	O
new	O
types	O
,	O
recurse	O
,	O
or	O
perform	O
type	O
evaluation	O
and	O
in	O
effect	O
are	O
limited	O
to	O
pre-compilation	O
text-substitution	O
and	O
text-inclusion/exclusion	O
.	O
</s>
<s>
In	O
other	O
words	O
,	O
macros	O
can	O
control	O
compilation	B-Language
flow	O
based	O
on	O
pre-defined	O
symbols	O
but	O
cannot	O
,	O
unlike	O
templates	B-Application
,	O
independently	O
instantiate	O
new	O
symbols	O
.	O
</s>
<s>
Templates	B-Application
are	O
a	O
tool	O
for	O
static	O
polymorphism	B-Application
(	O
see	O
below	O
)	O
and	O
generic	B-Language
programming	I-Language
.	O
</s>
<s>
In	O
addition	O
,	O
templates	B-Application
are	O
a	O
compile-time	B-Application
mechanism	O
in	O
C++	B-Language
that	O
is	O
Turing-complete	O
,	O
meaning	O
that	O
any	O
computation	O
expressible	O
by	O
a	O
computer	O
program	O
can	O
be	O
computed	O
,	O
in	O
some	O
form	O
,	O
by	O
a	O
template	B-Language
metaprogram	I-Language
prior	O
to	O
runtime	B-Library
.	O
</s>
<s>
In	O
summary	O
,	O
a	O
template	B-Application
is	O
a	O
compile-time	B-Application
parameterized	O
function	O
or	O
class	O
written	O
without	O
knowledge	O
of	O
the	O
specific	O
arguments	O
used	O
to	O
instantiate	O
it	O
.	O
</s>
<s>
In	O
this	O
manner	O
,	O
templates	B-Application
provide	O
a	O
way	O
to	O
decouple	O
generic	B-Language
,	O
broadly	O
applicable	O
aspects	O
of	O
functions	O
and	O
classes	O
(	O
encoded	O
in	O
templates	B-Application
)	O
from	O
specific	O
aspects	O
(	O
encoded	O
in	O
template	B-Application
parameters	O
)	O
without	O
sacrificing	O
performance	O
due	O
to	O
abstraction	B-Application
.	O
</s>
<s>
C++	B-Language
introduces	O
object-oriented	B-Language
programming	I-Language
(	O
OOP	O
)	O
features	O
to	O
C	B-Language
.	O
It	O
offers	O
classes	O
,	O
which	O
provide	O
the	O
four	O
features	O
commonly	O
present	O
in	O
OOP	O
(	O
and	O
some	O
non-OOP	O
)	O
languages	O
:	O
abstraction	B-Application
,	O
encapsulation	B-Application
,	O
inheritance	B-Language
,	O
and	O
polymorphism	B-Application
.	O
</s>
<s>
One	O
distinguishing	O
feature	B-Architecture
of	O
C++	B-Language
classes	O
compared	O
to	O
classes	O
in	O
other	O
programming	O
languages	O
is	O
support	O
for	O
deterministic	O
destructors	B-Language
,	O
which	O
in	O
turn	O
provide	O
support	O
for	O
the	O
Resource	B-Application
Acquisition	I-Application
is	I-Application
Initialization	I-Application
(	O
RAII	B-Application
)	O
concept	O
.	O
</s>
<s>
Encapsulation	B-Application
is	O
the	O
hiding	O
of	O
information	O
to	O
ensure	O
that	O
data	O
structures	O
and	O
operators	O
are	O
used	O
as	O
intended	O
and	O
to	O
make	O
the	O
usage	O
model	O
more	O
obvious	O
to	O
the	O
developer	O
.	O
</s>
<s>
C++	B-Language
provides	O
the	O
ability	O
to	O
define	O
classes	O
and	O
functions	O
as	O
its	O
primary	O
encapsulation	B-Application
mechanisms	O
.	O
</s>
<s>
Within	O
a	O
class	O
,	O
members	O
can	O
be	O
declared	O
as	O
either	O
public	O
,	O
protected	O
,	O
or	O
private	O
to	O
explicitly	O
enforce	O
encapsulation	B-Application
.	O
</s>
<s>
The	O
object-oriented	B-Language
principle	O
ensures	O
the	O
encapsulation	B-Application
of	O
all	O
and	O
only	O
the	O
functions	O
that	O
access	O
the	O
internal	O
representation	O
of	O
a	O
type	O
.	O
</s>
<s>
C++	B-Language
supports	O
this	O
principle	O
via	O
member	O
functions	O
and	O
friend	O
functions	O
,	O
but	O
it	O
does	O
not	O
enforce	O
it	O
.	O
</s>
<s>
Therefore	O
,	O
C++	B-Language
supports	O
not	O
just	O
object-oriented	B-Language
programming	I-Language
,	O
but	O
other	O
decomposition	O
paradigms	O
such	O
as	O
modular	B-Architecture
programming	I-Architecture
.	O
</s>
<s>
Inheritance	B-Language
allows	O
one	O
data	O
type	O
to	O
acquire	O
properties	O
of	O
other	O
data	O
types	O
.	O
</s>
<s>
Inheritance	B-Language
from	O
a	O
base	B-Application
class	I-Application
may	O
be	O
declared	O
as	O
public	O
,	O
protected	O
,	O
or	O
private	O
.	O
</s>
<s>
This	O
access	O
specifier	O
determines	O
whether	O
unrelated	O
and	O
derived	O
classes	O
can	O
access	O
the	O
inherited	O
public	O
and	O
protected	O
members	O
of	O
the	O
base	B-Application
class	I-Application
.	O
</s>
<s>
Only	O
public	O
inheritance	B-Language
corresponds	O
to	O
what	O
is	O
usually	O
meant	O
by	O
"	O
inheritance	B-Language
"	O
.	O
</s>
<s>
If	O
the	O
access	O
specifier	O
is	O
omitted	O
,	O
a	O
"	O
class	O
"	O
inherits	O
privately	O
,	O
while	O
a	O
"	O
struct	B-Application
"	O
inherits	O
publicly	O
.	O
</s>
<s>
Base	O
classes	O
may	O
be	O
declared	O
as	O
virtual	O
;	O
this	O
is	O
called	O
virtual	B-Application
inheritance	I-Application
.	O
</s>
<s>
Virtual	B-Application
inheritance	I-Application
ensures	O
that	O
only	O
one	O
instance	O
of	O
a	O
base	B-Application
class	I-Application
exists	O
in	O
the	O
inheritance	B-Language
graph	O
,	O
avoiding	O
some	O
of	O
the	O
ambiguity	O
problems	O
of	O
multiple	B-Application
inheritance	I-Application
.	O
</s>
<s>
Multiple	B-Application
inheritance	I-Application
is	O
a	O
C++	B-Language
feature	B-Architecture
allowing	O
a	O
class	O
to	O
be	O
derived	O
from	O
more	O
than	O
one	O
base	B-Application
class	I-Application
;	O
this	O
allows	O
for	O
more	O
elaborate	O
inheritance	B-Language
relationships	O
.	O
</s>
<s>
Some	O
other	O
languages	O
,	O
such	O
as	O
C#	B-Application
or	O
Java	B-Language
,	O
accomplish	O
something	O
similar	O
(	O
although	O
more	O
limited	O
)	O
by	O
allowing	O
inheritance	B-Language
of	O
multiple	O
interfaces	B-Application
while	O
restricting	O
the	O
number	O
of	O
base	O
classes	O
to	O
one	O
(	O
interfaces	B-Application
,	O
unlike	O
classes	O
,	O
provide	O
only	O
declarations	O
of	O
member	O
functions	O
,	O
no	O
implementation	O
or	O
member	O
data	O
)	O
.	O
</s>
<s>
An	O
interface	O
as	O
in	O
C#	B-Application
and	O
Java	B-Language
can	O
be	O
defined	O
in	O
C++	B-Language
as	O
a	O
class	O
containing	O
only	O
pure	B-Application
virtual	I-Application
functions	I-Application
,	O
often	O
known	O
as	O
an	O
abstract	B-Application
base	I-Application
class	I-Application
or	O
"	O
ABC	O
"	O
.	O
</s>
<s>
The	O
member	O
functions	O
of	O
such	O
an	O
abstract	B-Application
base	I-Application
class	I-Application
are	O
normally	O
explicitly	O
defined	O
in	O
the	O
derived	O
class	O
,	O
not	O
inherited	O
implicitly	O
.	O
</s>
<s>
C++	B-Language
virtual	B-Application
inheritance	I-Application
exhibits	O
an	O
ambiguity	O
resolution	O
feature	B-Architecture
called	O
dominance	B-Application
.	O
</s>
<s>
C++	B-Language
provides	O
more	O
than	O
35	O
operators	O
,	O
covering	O
basic	O
arithmetic	O
,	O
bit	O
manipulation	O
,	O
indirection	O
,	O
comparisons	O
,	O
logical	O
operations	O
and	O
others	O
.	O
</s>
<s>
Almost	O
all	O
operators	O
can	O
be	O
overloaded	O
for	O
user-defined	O
types	O
,	O
with	O
a	O
few	O
notable	O
exceptions	B-General_Concept
such	O
as	O
member	O
access	O
(	O
.	O
</s>
<s>
The	O
rich	O
set	O
of	O
overloadable	O
operators	O
is	O
central	O
to	O
making	O
user-defined	O
types	O
in	O
C++	B-Language
seem	O
like	O
built-in	O
types	O
.	O
</s>
<s>
Overloadable	O
operators	O
are	O
also	O
an	O
essential	O
part	O
of	O
many	O
advanced	O
C++	B-Language
programming	O
techniques	O
,	O
such	O
as	O
smart	B-Language
pointers	I-Language
.	O
</s>
<s>
Overloading	B-Application
an	O
operator	O
does	O
not	O
change	O
the	O
precedence	O
of	O
calculations	O
involving	O
the	O
operator	O
,	O
nor	O
does	O
it	O
change	O
the	O
number	O
of	O
operands	O
that	O
the	O
operator	O
uses	O
(	O
any	O
operand	O
may	O
however	O
be	O
ignored	O
by	O
the	O
operator	O
,	O
though	O
it	O
will	O
be	O
evaluated	O
prior	O
to	O
execution	O
)	O
.	O
</s>
<s>
Polymorphism	B-Application
enables	O
one	O
common	O
interface	O
for	O
many	O
implementations	O
,	O
and	O
for	O
objects	O
to	O
act	O
differently	O
under	O
different	O
circumstances	O
.	O
</s>
<s>
C++	B-Language
supports	O
several	O
kinds	O
of	O
static	O
(	O
resolved	O
at	O
compile-time	B-Application
)	O
and	O
dynamic	O
(	O
resolved	O
at	O
run-time	B-Library
)	O
polymorphisms	B-Application
,	O
supported	O
by	O
the	O
language	O
features	O
described	O
above	O
.	O
</s>
<s>
Compile-time	B-Language
polymorphism	I-Language
does	O
not	O
allow	O
for	O
certain	O
run-time	B-Library
decisions	O
,	O
while	O
runtime	B-Library
polymorphism	B-Application
typically	O
incurs	O
a	O
performance	O
penalty	O
.	O
</s>
<s>
Function	B-Language
overloading	I-Language
allows	O
programs	O
to	O
declare	O
multiple	O
functions	O
having	O
the	O
same	O
name	O
but	O
with	O
different	O
arguments	O
(	O
i.e.	O
</s>
<s>
ad	O
hoc	O
polymorphism	B-Application
)	O
.	O
</s>
<s>
The	O
type	O
returned	O
by	O
the	O
function	O
is	O
not	O
used	O
to	O
distinguish	O
overloaded	B-Language
functions	I-Language
and	O
differing	O
return	O
types	O
would	O
result	O
in	O
a	O
compile-time	B-Application
error	I-Application
message	O
.	O
</s>
<s>
When	O
declaring	O
a	O
function	O
,	O
a	O
programmer	O
can	O
specify	O
for	O
one	O
or	O
more	O
parameters	O
a	O
default	B-Language
value	I-Language
.	O
</s>
<s>
Doing	O
so	O
allows	O
the	O
parameters	O
with	O
defaults	O
to	O
optionally	O
be	O
omitted	O
when	O
the	O
function	O
is	O
called	O
,	O
in	O
which	O
case	O
the	O
default	B-Language
arguments	I-Language
will	O
be	O
used	O
.	O
</s>
<s>
When	O
a	O
function	O
is	O
called	O
with	O
fewer	O
arguments	O
than	O
there	O
are	O
declared	O
parameters	O
,	O
explicit	O
arguments	O
are	O
matched	O
to	O
parameters	O
in	O
left-to-right	O
order	O
,	O
with	O
any	O
unmatched	O
parameters	O
at	O
the	O
end	O
of	O
the	O
parameter	O
list	O
being	O
assigned	O
their	O
default	B-Language
arguments	I-Language
.	O
</s>
<s>
In	O
many	O
cases	O
,	O
specifying	O
default	B-Language
arguments	I-Language
in	O
a	O
single	O
function	O
declaration	O
is	O
preferable	O
to	O
providing	O
overloaded	B-Language
function	I-Language
definitions	O
with	O
different	O
numbers	O
of	O
parameters	O
.	O
</s>
<s>
Templates	B-Application
in	O
C++	B-Language
provide	O
a	O
sophisticated	O
mechanism	O
for	O
writing	O
generic	B-Language
,	O
polymorphic	B-Application
code	O
(	O
i.e.	O
</s>
<s>
parametric	O
polymorphism	B-Application
)	O
.	O
</s>
<s>
In	O
particular	O
,	O
through	O
the	O
curiously	B-Language
recurring	I-Language
template	I-Language
pattern	I-Language
,	O
it	O
's	O
possible	O
to	O
implement	O
a	O
form	O
of	O
static	O
polymorphism	B-Application
that	O
closely	O
mimics	O
the	O
syntax	O
for	O
overriding	B-Language
virtual	B-Application
functions	I-Application
.	O
</s>
<s>
Because	O
C++	B-Application
templates	I-Application
are	O
type-aware	O
and	O
Turing-complete	O
,	O
they	O
can	O
also	O
be	O
used	O
to	O
let	O
the	O
compiler	B-Language
resolve	O
recursive	O
conditionals	O
and	O
generate	O
substantial	O
programs	O
through	O
template	B-Language
metaprogramming	I-Language
.	O
</s>
<s>
Contrary	O
to	O
some	O
opinion	O
,	O
template	B-Application
code	O
will	O
not	O
generate	O
a	O
bulk	O
code	O
after	O
compilation	B-Language
with	O
the	O
proper	O
compiler	B-Language
settings	O
.	O
</s>
<s>
Variable	O
pointers	O
and	O
references	O
to	O
a	O
base	B-Application
class	I-Application
type	O
in	O
C++	B-Language
can	O
also	O
refer	O
to	O
objects	O
of	O
any	O
derived	O
classes	O
of	O
that	O
type	O
.	O
</s>
<s>
This	O
allows	O
arrays	O
and	O
other	O
kinds	O
of	O
containers	B-Application
to	O
hold	O
pointers	O
to	O
objects	O
of	O
differing	O
types	O
(	O
references	O
cannot	O
be	O
directly	O
held	O
in	O
containers	B-Application
)	O
.	O
</s>
<s>
This	O
enables	O
dynamic	O
(	O
run-time	B-Library
)	O
polymorphism	B-Application
,	O
where	O
the	O
referred	O
objects	O
can	O
behave	O
differently	O
,	O
depending	O
on	O
their	O
(	O
actual	O
,	O
derived	O
)	O
types	O
.	O
</s>
<s>
C++	B-Language
also	O
provides	O
the	O
operator	O
,	O
which	O
allows	O
code	O
to	O
safely	O
attempt	O
conversion	O
of	O
an	O
object	O
,	O
via	O
a	O
base	O
reference/pointer	O
,	O
to	O
a	O
more	O
derived	O
type	O
:	O
downcasting	O
.	O
</s>
<s>
(	O
Upcasting	O
,	O
conversion	O
to	O
a	O
more	O
general	O
type	O
,	O
can	O
always	O
be	O
checked/performed	O
at	O
compile-time	B-Application
via	O
,	O
as	O
ancestral	O
classes	O
are	O
specified	O
in	O
the	O
derived	O
class	O
's	O
interface	O
,	O
visible	O
to	O
all	O
callers	O
.	O
)	O
</s>
<s>
relies	O
on	O
run-time	B-Application
type	I-Application
information	I-Application
(	O
RTTI	B-Application
)	O
,	O
metadata	O
in	O
the	O
program	O
that	O
enables	O
differentiating	O
types	O
and	O
their	O
relationships	O
.	O
</s>
<s>
If	O
a	O
to	O
a	O
pointer	O
fails	O
,	O
the	O
result	O
is	O
the	O
constant	O
,	O
whereas	O
if	O
the	O
destination	O
is	O
a	O
reference	B-Language
(	O
which	O
cannot	O
be	O
null	O
)	O
,	O
the	O
cast	O
throws	O
an	O
exception	O
.	O
</s>
<s>
Objects	O
known	O
to	O
be	O
of	O
a	O
certain	O
derived	O
type	O
can	O
be	O
cast	O
to	O
that	O
with	O
,	O
bypassing	O
RTTI	B-Application
and	O
the	O
safe	O
runtime	B-Library
type-checking	O
of	O
,	O
so	O
this	O
should	O
be	O
used	O
only	O
if	O
the	O
programmer	O
is	O
very	O
confident	O
the	O
cast	O
is	O
,	O
and	O
will	O
always	O
be	O
,	O
valid	O
.	O
</s>
<s>
Ordinarily	O
,	O
when	O
a	O
function	O
in	O
a	O
derived	O
class	O
overrides	B-Language
a	O
function	O
in	O
a	O
base	B-Application
class	I-Application
,	O
the	O
function	O
to	O
call	O
is	O
determined	O
by	O
the	O
type	O
of	O
the	O
object	O
.	O
</s>
<s>
Hence	O
,	O
at	O
compile	B-Application
time	I-Application
,	O
it	O
may	O
not	O
be	O
possible	O
to	O
determine	O
the	O
type	O
of	O
the	O
object	O
and	O
therefore	O
the	O
correct	O
function	O
to	O
call	O
,	O
given	O
only	O
a	O
base	B-Application
class	I-Application
pointer	O
;	O
the	O
decision	O
is	O
therefore	O
put	O
off	O
until	O
runtime	B-Library
.	O
</s>
<s>
Virtual	B-Application
member	I-Application
functions	I-Application
or	O
methods	O
allow	O
the	O
most	O
specific	O
implementation	O
of	O
the	O
function	O
to	O
be	O
called	O
,	O
according	O
to	O
the	O
actual	O
run-time	B-Library
type	O
of	O
the	O
object	O
.	O
</s>
<s>
In	O
C++	B-Language
implementations	O
,	O
this	O
is	O
commonly	O
done	O
using	O
virtual	B-Language
function	I-Language
tables	I-Language
.	O
</s>
<s>
If	O
the	O
object	O
type	O
is	O
known	O
,	O
this	O
may	O
be	O
bypassed	O
by	O
prepending	O
a	O
fully	B-Protocol
qualified	I-Protocol
class	I-Protocol
name	I-Protocol
before	O
the	O
function	O
call	O
,	O
but	O
in	O
general	O
calls	O
to	O
virtual	B-Application
functions	I-Application
are	O
resolved	O
at	O
run	B-Library
time	I-Library
.	O
</s>
<s>
In	O
addition	O
to	O
standard	O
member	O
functions	O
,	O
operator	O
overloads	B-Language
and	O
destructors	B-Language
can	O
be	O
virtual	O
.	O
</s>
<s>
An	O
inexact	O
rule	O
based	O
on	O
practical	O
experience	O
states	O
that	O
if	O
any	O
function	O
in	O
the	O
class	O
is	O
virtual	O
,	O
the	O
destructor	B-Language
should	O
be	O
as	O
well	O
.	O
</s>
<s>
As	O
the	O
type	O
of	O
an	O
object	O
at	O
its	O
creation	O
is	O
known	O
at	O
compile	B-Application
time	I-Application
,	O
constructors	O
,	O
and	O
by	O
extension	O
copy	O
constructors	O
,	O
cannot	O
be	O
virtual	O
.	O
</s>
<s>
In	O
such	O
a	O
case	O
,	O
a	O
common	O
solution	O
is	O
to	O
create	O
a	O
(	O
or	O
similar	O
)	O
virtual	B-Application
function	I-Application
that	O
creates	O
and	O
returns	O
a	O
copy	O
of	O
the	O
derived	O
class	O
when	O
called	O
.	O
</s>
<s>
A	O
class	O
containing	O
a	O
pure	B-Application
virtual	I-Application
function	I-Application
is	O
called	O
an	O
abstract	O
class	O
.	O
</s>
<s>
Any	O
derived	O
class	O
inherits	O
the	O
virtual	B-Application
function	I-Application
as	O
pure	O
and	O
must	O
provide	O
a	O
non-pure	O
definition	O
of	O
it	O
(	O
and	O
all	O
other	O
pure	B-Application
virtual	I-Application
functions	I-Application
)	O
before	O
objects	O
of	O
the	O
derived	O
class	O
can	O
be	O
created	O
.	O
</s>
<s>
C++	B-Language
provides	O
support	O
for	O
anonymous	B-General_Concept
functions	I-General_Concept
,	O
also	O
known	O
as	O
lambda	B-Language
expressions	I-Language
,	O
with	O
the	O
following	O
form	O
:	O
</s>
<s>
Since	O
C++20	B-Language
,	O
the	O
keyword	O
is	O
optional	O
for	O
template	B-Application
parameters	O
of	O
lambda	B-Language
expressions	I-Language
:	O
</s>
<s>
If	O
the	O
lambda	B-General_Concept
takes	O
no	O
parameters	O
,	O
and	O
no	O
return	O
type	O
or	O
other	O
specifiers	O
are	O
used	O
,	O
the	O
(	O
)	O
can	O
be	O
omitted	O
,	O
that	O
is	O
,	O
</s>
<s>
The	O
return	O
type	O
of	O
a	O
lambda	B-General_Concept
expression	I-General_Concept
can	O
be	O
automatically	O
inferred	O
,	O
if	O
possible	O
,	O
e.g.	O
</s>
<s>
The	O
list	O
supports	O
the	O
definition	O
of	O
closures	B-Language
.	O
</s>
<s>
Such	O
lambda	B-Language
expressions	I-Language
are	O
defined	O
in	O
the	O
standard	O
as	O
syntactic	O
sugar	O
for	O
an	O
unnamed	O
function	B-Language
object	I-Language
.	O
</s>
<s>
Exception	B-General_Concept
handling	I-General_Concept
is	O
used	O
to	O
communicate	O
the	O
existence	O
of	O
a	O
runtime	B-Library
problem	O
or	O
error	O
from	O
where	O
it	O
was	O
detected	O
to	O
where	O
the	O
issue	O
can	O
be	O
handled	O
.	O
</s>
<s>
Should	O
an	O
error	O
occur	O
,	O
an	O
exception	O
is	O
thrown	O
(	O
raised	O
)	O
,	O
which	O
is	O
then	O
caught	O
by	O
the	O
nearest	O
suitable	O
exception	B-General_Concept
handler	I-General_Concept
.	O
</s>
<s>
The	O
exception	O
causes	O
the	O
current	O
scope	O
to	O
be	O
exited	O
,	O
and	O
also	O
each	O
outer	O
scope	O
(	O
propagation	O
)	O
until	O
a	O
suitable	O
handler	O
is	O
found	O
,	O
calling	O
in	O
turn	O
the	O
destructors	B-Language
of	O
any	O
objects	O
in	O
these	O
exited	O
scopes	O
.	O
</s>
<s>
Some	O
C++	B-Language
style	O
guides	O
,	O
such	O
as	O
Google	O
's	O
,	O
LLVM	B-Application
's	O
,	O
and	O
Qt	O
's	O
forbid	O
the	O
usage	O
of	O
exceptions	B-General_Concept
.	O
</s>
<s>
The	O
exceptions	B-General_Concept
are	O
handled	O
in	O
separate	O
blocks	O
(	O
the	O
handlers	O
)	O
;	O
each	O
block	O
can	O
have	O
multiple	O
exception	B-General_Concept
handlers	I-General_Concept
,	O
as	O
it	O
is	O
visible	O
in	O
the	O
example	O
below	O
.	O
</s>
<s>
It	O
is	O
also	O
possible	O
to	O
raise	O
exceptions	B-General_Concept
purposefully	O
,	O
using	O
the	O
keyword	O
;	O
these	O
exceptions	B-General_Concept
are	O
handled	O
in	O
the	O
usual	O
way	O
.	O
</s>
<s>
In	O
some	O
cases	O
,	O
exceptions	B-General_Concept
cannot	O
be	O
used	O
due	O
to	O
technical	O
reasons	O
.	O
</s>
<s>
One	O
such	O
example	O
is	O
a	O
critical	O
component	O
of	O
an	O
embedded	B-Application
system	O
,	O
where	O
every	O
operation	O
must	O
be	O
guaranteed	O
to	O
complete	O
within	O
a	O
specified	O
amount	O
of	O
time	O
.	O
</s>
<s>
This	O
cannot	O
be	O
determined	O
with	O
exceptions	B-General_Concept
as	O
no	O
tools	O
exist	O
to	O
determine	O
the	O
maximum	O
time	O
required	O
for	O
an	O
exception	O
to	O
be	O
handled	O
.	O
</s>
<s>
Unlike	O
signal	B-Operating_System
handling	I-Operating_System
,	O
in	O
which	O
the	O
handling	O
function	O
is	O
called	O
from	O
the	O
point	O
of	O
failure	O
,	O
exception	B-General_Concept
handling	I-General_Concept
exits	O
the	O
current	O
scope	O
before	O
the	O
catch	O
block	O
is	O
entered	O
,	O
which	O
may	O
be	O
located	O
in	O
the	O
current	O
function	O
or	O
any	O
of	O
the	O
previous	O
function	O
calls	O
currently	O
on	O
the	O
stack	B-General_Concept
.	O
</s>
<s>
;	O
it	O
includes	O
aggregate	O
types	O
(	O
vectors	O
,	O
lists	B-Data_Structure
,	O
maps	O
,	O
sets	O
,	O
queues	O
,	O
stacks	O
,	O
arrays	O
,	O
tuples	O
)	O
,	O
algorithms	O
(	O
find	O
,	O
for_each	O
,	O
binary_search	O
,	O
random_shuffle	O
,	O
etc	O
.	O
</s>
<s>
)	O
,	O
input/output	O
facilities	O
(	O
iostream	O
,	O
for	O
reading	O
from	O
and	O
writing	O
to	O
the	O
console	O
and	O
files	O
)	O
,	O
filesystem	O
library	B-Library
,	O
localisation	O
support	O
,	O
smart	B-Language
pointers	I-Language
for	O
automatic	B-General_Concept
memory	I-General_Concept
management	I-General_Concept
,	O
regular	B-Language
expression	I-Language
support	O
,	O
multi-threading	B-Operating_System
library	B-Library
,	O
atomics	O
support	O
(	O
allowing	O
a	O
variable	O
to	O
be	O
read	O
or	O
written	O
to	O
by	O
at	O
most	O
one	O
thread	B-Operating_System
at	O
a	O
time	O
without	O
any	O
external	O
synchronisation	O
)	O
,	O
time	O
utilities	O
(	O
measurement	O
,	O
getting	O
current	O
time	O
,	O
etc	O
.	O
</s>
<s>
)	O
,	O
a	O
system	O
for	O
converting	O
error	B-General_Concept
reporting	I-General_Concept
that	O
does	O
n't	O
use	O
C++	B-Language
exceptions	B-General_Concept
into	O
C++	B-Language
exceptions	B-General_Concept
,	O
a	O
random	O
number	O
generator	O
and	O
a	O
slightly	O
modified	O
version	O
of	O
the	B-Language
C	I-Language
standard	I-Language
library	I-Language
(	O
to	O
make	O
it	O
comply	O
with	O
the	O
C++	B-Language
type	O
system	O
)	O
.	O
</s>
<s>
A	O
large	O
part	O
of	O
the	O
C++	B-Language
library	B-Library
is	O
based	O
on	O
the	O
Standard	B-Application
Template	I-Application
Library	I-Application
(	O
STL	O
)	O
.	O
</s>
<s>
Useful	O
tools	O
provided	O
by	O
the	O
STL	O
include	O
containers	B-Application
as	O
the	O
collections	O
of	O
objects	O
(	O
such	O
as	O
vectors	O
and	O
lists	B-Data_Structure
)	O
,	O
iterators	O
that	O
provide	O
array-like	O
access	O
to	O
containers	B-Application
,	O
and	O
algorithms	O
that	O
perform	O
operations	O
such	O
as	O
searching	O
and	O
sorting	O
.	O
</s>
<s>
Furthermore	O
,	O
(	O
multi	O
)	O
maps	O
(	O
associative	B-Application
arrays	I-Application
)	O
and	O
(	O
multi	O
)	O
sets	O
are	O
provided	O
,	O
all	O
of	O
which	O
export	O
compatible	O
interfaces	B-Application
.	O
</s>
<s>
Therefore	O
,	O
using	O
templates	B-Application
it	O
is	O
possible	O
to	O
write	O
generic	B-Language
algorithms	I-Language
that	O
work	O
with	O
any	O
container	B-Application
or	O
on	O
any	O
sequence	O
defined	O
by	O
iterators	O
.	O
</s>
<s>
As	O
in	O
C	B-Language
,	O
the	O
features	O
of	O
the	O
library	B-Library
are	O
accessed	O
by	O
using	O
the	O
directive	O
to	O
include	O
a	O
standard	B-Library
header	I-Library
.	O
</s>
<s>
The	O
C++	B-Language
Standard	I-Language
Library	I-Language
provides	O
105	O
standard	B-Library
headers	I-Library
,	O
of	O
which	O
27	O
are	O
deprecated	O
.	O
</s>
<s>
The	O
standard	O
incorporates	O
the	O
STL	O
that	O
was	O
originally	O
designed	O
by	O
Alexander	O
Stepanov	O
,	O
who	O
experimented	O
with	O
generic	B-Language
algorithms	I-Language
and	O
containers	B-Application
for	O
many	O
years	O
.	O
</s>
<s>
When	O
he	O
started	O
with	O
C++	B-Language
,	O
he	O
finally	O
found	O
a	O
language	O
where	O
it	O
was	O
possible	O
to	O
create	O
generic	B-Language
algorithms	I-Language
(	O
e.g.	O
,	O
STL	O
sort	O
)	O
that	O
perform	O
even	O
better	O
than	O
,	O
for	O
example	O
,	O
the	B-Language
C	I-Language
standard	I-Language
library	I-Language
qsort	O
,	O
thanks	O
to	O
C++	B-Language
features	O
like	O
using	O
inlining	O
and	O
compile-time	B-Application
binding	O
instead	O
of	O
function	O
pointers	O
.	O
</s>
<s>
The	O
standard	O
does	O
not	O
refer	O
to	O
it	O
as	O
"	O
STL	O
"	O
,	O
as	O
it	O
is	O
merely	O
a	O
part	O
of	O
the	O
standard	B-Library
library	I-Library
,	O
but	O
the	O
term	O
is	O
still	O
widely	O
used	O
to	O
distinguish	O
it	O
from	O
the	O
rest	O
of	O
the	O
standard	B-Library
library	I-Library
(	O
input/output	O
streams	O
,	O
internationalization	O
,	O
diagnostics	O
,	O
the	O
C	B-Language
library	I-Language
subset	O
,	O
etc	O
.	O
</s>
<s>
Most	O
C++	B-Language
compilers	B-Language
,	O
and	O
all	O
major	O
ones	O
,	O
provide	O
a	O
standards-conforming	O
implementation	O
of	O
the	O
C++	B-Language
standard	I-Language
library	I-Language
.	O
</s>
<s>
The	O
C++	B-Language
Core	O
Guidelines	O
are	O
an	O
initiative	O
led	O
by	O
Bjarne	O
Stroustrup	O
,	O
the	O
inventor	O
of	O
C++	B-Language
,	O
and	O
Herb	O
Sutter	O
,	O
the	O
convener	O
and	O
chair	O
of	O
the	O
C++	B-Language
ISO	O
Working	O
Group	O
,	O
to	O
help	O
programmers	O
write	O
'	O
Modern	O
C++	B-Language
 '	O
by	O
using	O
best	O
practices	O
for	O
the	O
language	O
standards	O
C++11	B-Language
and	O
newer	O
,	O
and	O
to	O
help	O
developers	O
of	O
compilers	B-Language
and	O
static	O
checking	O
tools	O
to	O
create	O
rules	O
for	O
catching	O
bad	O
programming	O
practices	O
.	O
</s>
<s>
The	O
main	O
aim	O
is	O
to	O
efficiently	O
and	O
consistently	O
write	O
type	O
and	O
resource	O
safe	O
C++	B-Language
.	O
</s>
<s>
The	O
Guidelines	O
are	O
accompanied	O
by	O
the	O
Guideline	O
Support	O
Library	B-Library
(	O
GSL	O
)	O
,	O
a	O
header	O
only	O
library	B-Library
of	O
types	O
and	O
functions	O
to	O
implement	O
the	O
Core	O
Guidelines	O
and	O
static	O
checker	O
tools	O
for	O
enforcing	O
Guideline	O
rules	O
.	O
</s>
<s>
To	O
give	O
compiler	B-Language
vendors	O
greater	O
freedom	O
,	O
the	O
C++	B-Language
standards	O
committee	O
decided	O
not	O
to	O
dictate	O
the	O
implementation	O
of	O
name	B-Language
mangling	I-Language
,	O
exception	B-General_Concept
handling	I-General_Concept
,	O
and	O
other	O
implementation-specific	O
features	O
.	O
</s>
<s>
The	O
downside	O
of	O
this	O
decision	O
is	O
that	O
object	B-Language
code	I-Language
produced	O
by	O
different	O
compilers	B-Language
is	O
expected	O
to	O
be	O
incompatible	O
.	O
</s>
<s>
There	O
were	O
,	O
however	O
,	O
attempts	O
to	O
standardize	O
compilers	B-Language
for	O
particular	O
machines	O
or	O
operating	B-General_Concept
systems	I-General_Concept
(	O
for	O
example	O
C++	B-Language
ABI	O
)	O
,	O
though	O
they	O
seem	O
to	O
be	O
largely	O
abandoned	O
now	O
.	O
</s>
<s>
C++	B-Language
is	O
often	O
considered	O
to	O
be	O
a	O
superset	O
of	O
C	B-Language
but	O
this	O
is	O
not	O
strictly	O
true	O
.	O
</s>
<s>
Most	O
C	B-Language
code	O
can	O
easily	O
be	O
made	O
to	O
compile	B-Language
correctly	O
in	O
C++	B-Language
but	O
there	O
are	O
a	O
few	O
differences	O
that	O
cause	O
some	O
valid	O
C	B-Language
code	O
to	O
be	O
invalid	O
or	O
behave	O
differently	O
in	O
C++	B-Language
.	O
</s>
<s>
For	O
example	O
,	O
C	B-Language
allows	O
implicit	O
conversion	O
from	O
to	O
other	O
pointer	O
types	O
but	O
C++	B-Language
does	O
not	O
(	O
for	O
type	O
safety	O
reasons	O
)	O
.	O
</s>
<s>
Also	O
,	O
C++	B-Language
defines	O
many	O
new	O
keywords	O
,	O
such	O
as	O
and	O
,	O
which	O
may	O
be	O
used	O
as	O
identifiers	O
(	O
for	O
example	O
,	O
variable	O
names	O
)	O
in	O
a	O
C	B-Language
program	I-Language
.	O
</s>
<s>
Some	O
incompatibilities	O
have	O
been	O
removed	O
by	O
the	O
1999	O
revision	O
of	O
the	O
C	B-Language
standard	O
(	O
C99	B-Language
)	O
,	O
which	O
now	O
supports	O
C++	B-Language
features	O
such	O
as	O
line	O
comments	O
(	O
)	O
and	O
declarations	O
mixed	O
with	O
code	O
.	O
</s>
<s>
On	O
the	O
other	O
hand	O
,	O
C99	B-Language
introduced	O
a	O
number	O
of	O
new	O
features	O
that	O
C++	B-Language
did	O
not	O
support	O
that	O
were	O
incompatible	O
or	O
redundant	O
in	O
C++	B-Language
,	O
such	O
as	O
variable-length	B-Data_Structure
arrays	I-Data_Structure
,	O
native	O
complex-number	O
types	O
(	O
however	O
,	O
the	O
class	O
in	O
the	O
C++	B-Language
standard	I-Language
library	I-Language
provides	O
similar	O
functionality	O
,	O
although	O
not	O
code-compatible	O
)	O
,	O
designated	O
initializers	O
,	O
compound	O
literals	O
,	O
and	O
the	O
keyword	O
.	O
</s>
<s>
Some	O
of	O
the	O
C99-introduced	O
features	O
were	O
included	O
in	O
the	O
subsequent	O
version	O
of	O
the	O
C++	B-Language
standard	O
,	O
C++11	B-Language
(	O
out	O
of	O
those	O
which	O
were	O
not	O
redundant	O
)	O
.	O
</s>
<s>
However	O
,	O
the	O
C++11	B-Language
standard	O
introduces	O
new	O
incompatibilities	O
,	O
such	O
as	O
disallowing	O
assignment	O
of	O
a	O
string	O
literal	O
to	O
a	O
character	O
pointer	O
,	O
which	O
remains	O
valid	O
C	B-Language
.	O
</s>
<s>
To	O
intermix	O
C	B-Language
and	O
C++	B-Language
code	I-Language
,	O
any	O
function	O
declaration	O
or	O
definition	O
that	O
is	O
to	O
be	O
called	O
from/used	O
both	O
in	O
C	B-Language
and	O
C++	B-Language
must	O
be	O
declared	O
with	O
C	B-Language
linkage	O
by	O
placing	O
it	O
within	O
an	O
block	O
.	O
</s>
<s>
Such	O
a	O
function	O
may	O
not	O
rely	O
on	O
features	O
depending	O
on	O
name	B-Language
mangling	I-Language
(	O
i.e.	O
,	O
function	B-Language
overloading	I-Language
)	O
.	O
</s>
<s>
Despite	O
its	O
widespread	O
adoption	O
,	O
some	O
notable	O
programmers	O
have	O
criticized	O
the	O
C++	B-Language
language	I-Language
,	O
including	O
Linus	O
Torvalds	O
,	O
Richard	O
Stallman	O
,	O
Joshua	O
Bloch	O
,	O
Ken	O
Thompson	O
and	O
Donald	O
Knuth	O
.	O
</s>
<s>
One	O
of	O
the	O
most	O
often	O
criticised	O
points	O
of	O
C++	B-Language
is	O
its	O
perceived	O
complexity	O
as	O
a	O
language	O
,	O
with	O
the	O
criticism	O
that	O
a	O
large	O
number	O
of	O
non-orthogonal	O
features	O
in	O
practice	O
necessitates	O
restricting	O
code	O
to	O
a	O
subset	O
of	O
C++	B-Language
,	O
thus	O
eschewing	O
the	O
readability	O
benefits	O
of	O
common	O
style	O
and	O
idioms	O
.	O
</s>
<s>
As	O
expressed	O
by	O
Joshua	O
Bloch	O
:	O
I	O
think	O
C++	B-Language
was	O
pushed	O
well	O
beyond	O
its	O
complexity	O
threshold	O
,	O
and	O
yet	O
there	O
are	O
a	O
lot	O
of	O
people	O
programming	O
it	O
.	O
</s>
<s>
So	O
almost	O
every	O
shop	O
that	O
I	O
know	O
of	O
that	O
uses	O
C++	B-Language
says	O
,	O
"	O
Yes	O
,	O
we	O
're	O
using	O
C++	B-Language
but	O
we	O
're	O
not	O
doing	O
multiple-implementation	O
inheritance	O
and	O
we	O
're	O
not	O
using	O
operator	O
overloading.	O
”	O
There	O
are	O
just	O
a	O
bunch	O
of	O
features	O
that	O
you	O
're	O
not	O
going	O
to	O
use	O
because	O
the	O
complexity	O
of	O
the	O
resulting	O
code	O
is	O
too	O
high	O
.	O
</s>
<s>
Donald	O
Knuth	O
(	O
1993	O
,	O
commenting	O
on	O
pre-standardized	O
C++	B-Language
)	O
,	O
who	O
said	O
of	O
Edsger	O
Dijkstra	O
that	O
"	O
to	O
think	O
of	O
programming	O
in	O
C++	B-Language
"	O
"	O
would	O
make	O
him	O
physically	O
ill	O
"	O
:	O
The	O
problem	O
that	O
I	O
have	O
with	O
them	O
today	O
is	O
that	O
...	O
C++	B-Language
is	O
too	O
complicated	O
.	O
</s>
<s>
Whenever	O
the	O
C++	B-Language
language	I-Language
designers	O
had	O
two	O
competing	O
ideas	O
as	O
to	O
how	O
they	O
should	O
solve	O
some	O
problem	O
,	O
they	O
said	O
"	O
OK	O
,	O
we	O
'll	O
do	O
them	O
both	O
"	O
.	O
</s>
<s>
He	O
put	O
every	O
feature	B-Architecture
in	O
that	O
language	O
that	O
ever	O
existed	O
.	O
</s>
<s>
However	O
Brian	O
Kernighan	O
,	O
also	O
a	O
colleague	O
at	O
Bell	O
Labs	O
,	O
disputes	O
this	O
assessment	O
:	O
C++	B-Language
has	O
been	O
enormously	O
influential	O
.	O
</s>
<s>
...	O
Lots	O
of	O
people	O
say	O
C++	B-Language
is	O
too	O
big	O
and	O
too	O
complicated	O
etc	O
.	O
</s>
<s>
Now	O
a	O
lot	O
of	O
the	O
programs	O
that	O
we	O
take	O
for	O
granted	O
today	O
,	O
that	O
we	O
just	O
use	O
,	O
are	O
C++	B-Language
programs	I-Language
.	O
</s>
<s>
Stroustrup	O
himself	O
comments	O
that	O
C++	B-Language
semantics	O
are	O
much	O
cleaner	O
than	O
its	O
syntax	O
:	O
"	O
within	O
C++	B-Language
,	O
there	O
is	O
a	O
much	O
smaller	O
and	O
cleaner	O
language	O
struggling	O
to	O
get	O
out	O
"	O
.	O
</s>
<s>
Other	O
complaints	O
may	O
include	O
a	O
lack	O
of	O
reflection	B-Language
or	O
garbage	B-General_Concept
collection	I-General_Concept
,	O
long	O
compilation	B-Language
times	O
,	O
perceived	O
feature	B-Architecture
creep	O
,	O
and	O
verbose	O
error	O
messages	O
,	O
particularly	O
from	O
template	B-Language
metaprogramming	I-Language
.	O
</s>
