<s>
In	O
some	O
programming	O
languages	O
,	O
function	B-Language
overloading	I-Language
or	O
method	B-Language
overloading	I-Language
is	O
the	O
ability	O
to	O
create	O
multiple	O
functions	O
of	O
the	O
same	O
name	O
with	O
different	O
implementations	O
.	O
</s>
<s>
Calls	O
to	O
an	O
overloaded	B-Language
function	I-Language
will	O
run	O
a	O
specific	O
implementation	O
of	O
that	O
function	O
appropriate	O
to	O
the	O
context	O
of	O
the	O
call	O
,	O
allowing	O
one	O
function	O
call	O
to	O
perform	O
different	O
tasks	O
depending	O
on	O
context	O
.	O
</s>
<s>
For	O
example	O
,	O
and	O
are	O
overloaded	B-Language
functions	I-Language
.	O
</s>
<s>
A	O
common	O
error	O
would	O
be	O
to	O
assign	O
a	O
default	O
value	O
to	O
the	O
object	O
in	O
the	O
second	O
function	O
,	O
which	O
would	O
result	O
in	O
an	O
ambiguous	O
call	O
error	O
,	O
as	O
the	O
compiler	B-Language
would	O
n't	O
know	O
which	O
of	O
the	O
two	O
methods	O
to	O
use	O
.	O
</s>
<s>
Languages	O
which	O
support	O
function	B-Language
overloading	I-Language
include	O
,	O
but	O
are	O
not	O
necessarily	O
limited	O
to	O
,	O
the	O
following	O
:	O
</s>
<s>
It	O
is	O
a	O
classification	O
of	O
static	O
polymorphism	B-Application
in	O
which	O
a	O
function	O
call	O
is	O
resolved	O
using	O
some	O
"	O
best	O
match	O
"	O
algorithm	O
,	O
where	O
the	O
particular	O
function	O
to	O
call	O
is	O
resolved	O
by	O
finding	O
the	O
best	O
match	O
of	O
the	O
formal	O
parameter	O
types	O
with	O
the	O
actual	O
parameter	O
types	O
.	O
</s>
<s>
Function	B-Language
overloading	I-Language
is	O
usually	O
associated	O
with	O
statically-typed	O
programming	O
languages	O
that	O
enforce	O
type	O
checking	O
in	O
function	O
calls	O
.	O
</s>
<s>
An	O
overloaded	B-Language
function	I-Language
is	O
really	O
just	O
a	O
set	O
of	O
different	O
functions	O
that	O
happen	O
to	O
have	O
the	O
same	O
name	O
.	O
</s>
<s>
The	O
determination	O
of	O
which	O
function	O
to	O
use	O
for	O
a	O
particular	O
call	O
is	O
resolved	O
at	O
compile	B-Application
time	I-Application
.	O
</s>
<s>
In	O
Java	B-Language
,	O
function	B-Language
overloading	I-Language
is	O
also	O
known	O
as	O
compile-time	B-Application
polymorphism	B-Application
and	O
static	O
polymorphism	B-Application
.	O
</s>
<s>
Function	B-Language
overloading	I-Language
should	O
not	O
be	O
confused	O
with	O
forms	O
of	O
polymorphism	B-Application
where	O
the	O
choice	O
is	O
made	O
at	O
runtime	O
,	O
e.g.	O
</s>
<s>
through	O
virtual	B-Application
functions	I-Application
,	O
instead	O
of	O
statically	O
.	O
</s>
<s>
Constructors	O
,	O
used	O
to	O
create	O
instances	O
of	O
an	O
object	O
,	O
may	O
also	O
be	O
overloaded	O
in	O
some	O
object-oriented	B-Language
programming	I-Language
languages	I-Language
.	O
</s>
<s>
Whenever	O
multiple	O
constructors	O
are	O
needed	O
,	O
they	O
are	O
to	O
be	O
implemented	O
as	O
overloaded	B-Language
functions	I-Language
.	O
</s>
<s>
In	O
C++	B-Language
,	O
default	O
constructors	O
take	O
no	O
parameters	O
,	O
instantiating	O
the	O
object	O
members	B-Application
with	O
their	O
appropriate	O
default	O
values	O
,	O
"	O
which	O
is	O
normally	O
zero	O
for	O
numeral	O
fields	O
and	O
empty	O
string	O
for	O
string	O
fields	O
"	O
.	O
</s>
<s>
For	O
example	O
,	O
a	O
default	O
constructor	O
for	O
a	O
restaurant	O
bill	O
object	O
written	O
in	O
C++	B-Language
might	O
set	O
the	O
tip	O
to	O
15%	O
:	O
</s>
<s>
By	O
overloading	B-Application
the	O
constructor	O
,	O
one	O
could	O
pass	O
the	O
tip	O
and	O
total	O
as	O
parameters	O
at	O
creation	O
.	O
</s>
<s>
Now	O
a	O
function	O
that	O
creates	O
a	O
new	O
Bill	O
object	O
could	O
pass	O
two	O
values	O
into	O
the	O
constructor	O
and	O
set	O
the	O
data	O
members	B-Application
in	O
one	O
step	O
.	O
</s>
<s>
Another	O
reason	O
for	O
constructor	B-Language
overloading	I-Language
can	O
be	O
to	O
enforce	O
mandatory	O
data	O
members	B-Application
.	O
</s>
<s>
In	O
this	O
case	O
the	O
default	O
constructor	O
is	O
declared	O
private	O
or	O
protected	O
(	O
or	O
preferably	O
deleted	O
since	O
C++11	B-Language
)	O
to	O
make	O
it	O
inaccessible	O
from	O
outside	O
.	O
</s>
<s>
Two	O
issues	O
interact	O
with	O
and	O
complicate	O
function	B-Language
overloading	I-Language
:	O
Name	O
masking	O
(	O
due	O
to	O
scope	B-Language
)	O
and	O
implicit	O
type	O
conversion	O
.	O
</s>
<s>
If	O
a	O
function	O
is	O
declared	O
in	O
one	O
scope	B-Language
,	O
and	O
then	O
another	O
function	O
with	O
the	O
same	O
name	O
is	O
declared	O
in	O
an	O
inner	O
scope	B-Language
,	O
there	O
are	O
two	O
natural	O
possible	O
overloading	B-Application
behaviors	O
:	O
the	O
inner	O
declaration	O
masks	O
the	O
outer	O
declaration	O
(	O
regardless	O
of	O
signature	O
)	O
,	O
or	O
both	O
the	O
inner	O
declaration	O
and	O
the	O
outer	O
declaration	O
are	O
both	O
included	O
in	O
the	O
overload	B-Language
,	O
with	O
the	O
inner	O
declaration	O
masking	O
the	O
outer	O
declaration	O
only	O
if	O
the	O
signature	O
matches	O
.	O
</s>
<s>
The	O
first	O
is	O
taken	O
in	O
C++	B-Language
:	O
"	O
in	O
C++	B-Language
,	O
there	O
is	O
no	O
overloading	B-Application
across	O
scopes.	O
"	O
</s>
<s>
As	O
a	O
result	O
,	O
to	O
obtain	O
an	O
overload	B-Language
set	O
with	O
functions	O
declared	O
in	O
different	O
scopes	O
,	O
one	O
needs	O
to	O
explicitly	O
import	O
the	O
functions	O
from	O
the	O
outer	O
scope	B-Language
into	O
the	O
inner	O
scope	B-Language
,	O
with	O
the	O
keyword	O
.	O
</s>
<s>
Implicit	O
type	O
conversion	O
complicates	O
function	B-Language
overloading	I-Language
because	O
if	O
the	O
types	O
of	O
parameters	O
do	O
not	O
exactly	O
match	O
the	O
signature	O
of	O
one	O
of	O
the	O
overloaded	B-Language
functions	I-Language
,	O
but	O
can	O
match	O
after	O
type	O
conversion	O
,	O
resolution	O
depends	O
on	O
which	O
type	O
conversion	O
is	O
chosen	O
.	O
</s>
<s>
These	O
can	O
combine	O
in	O
confusing	O
ways	O
:	O
An	O
inexact	O
match	O
declared	O
in	O
an	O
inner	O
scope	B-Language
can	O
mask	O
an	O
exact	O
match	O
declared	O
in	O
an	O
outer	O
scope	B-Language
,	O
for	O
instance	O
.	O
</s>
<s>
For	O
example	O
,	O
to	O
have	O
a	O
derived	O
class	O
with	O
an	O
overloaded	B-Language
function	I-Language
taking	O
a	O
or	O
an	O
,	O
using	O
the	O
function	O
taking	O
an	O
from	O
the	O
base	O
class	O
,	O
in	O
C++	B-Language
,	O
one	O
would	O
write	O
:	O
</s>
<s>
Failing	O
to	O
include	O
the	O
results	O
in	O
an	O
parameter	O
passed	O
to	O
in	O
the	O
derived	O
class	O
being	O
converted	O
to	O
a	O
double	O
and	O
matching	O
the	O
function	O
in	O
the	O
derived	O
class	O
,	O
rather	O
than	O
in	O
the	O
base	O
class	O
;	O
Including	O
results	O
in	O
an	O
overload	B-Language
in	O
the	O
derived	O
class	O
and	O
thus	O
matching	O
the	O
function	O
in	O
the	O
base	O
class	O
.	O
</s>
<s>
If	O
a	O
method	O
is	O
designed	O
with	O
an	O
excessive	O
number	O
of	O
overloads	B-Language
,	O
it	O
may	O
be	O
difficult	O
for	O
developers	O
to	O
discern	O
which	O
overload	B-Language
is	O
being	O
called	O
simply	O
by	O
reading	O
the	O
code	O
.	O
</s>
<s>
An	O
IDE	O
can	O
perform	O
the	O
overload	B-Language
resolution	I-Language
and	O
display	O
(	O
or	O
navigate	O
to	O
)	O
the	O
correct	O
overload	B-Language
.	O
</s>
<s>
Type-based	O
overloading	B-Application
can	O
also	O
hamper	O
code	O
maintenance	O
,	O
where	O
code	O
updates	O
can	O
accidentally	O
change	O
which	O
method	B-Language
overload	I-Language
is	O
chosen	O
by	O
the	O
compiler	B-Language
.	O
</s>
