45 lines
1.6 KiB
Markdown
45 lines
1.6 KiB
Markdown
[over.pre]
|
||
|
||
# 12 Overloading [[over]](./#over)
|
||
|
||
## 12.1 Preamble [over.pre]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L9)
|
||
|
||
[*Note [1](#note-1)*:
|
||
|
||
Each of two or more entities with the same name in the same scope,
|
||
which must be functions or function templates,
|
||
is commonly called an âoverloadâ[.](#1.sentence-1)
|
||
|
||
â *end note*]
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L18)
|
||
|
||
When a function is designated in a call, which function
|
||
declaration is being referenced and the validity of the call
|
||
are determined by comparing the types
|
||
of the arguments at the point of use with the types of the parameters
|
||
in the declarations in the overload set[.](#2.sentence-1)
|
||
|
||
This function selection process is called[*overload resolution*](#def:overload_resolution "12.1 Preamble [over.pre]") and is defined in [[over.match]](over.match "12.2 Overload resolution")[.](#2.sentence-2)
|
||
|
||
[*Note [2](#note-2)*:
|
||
|
||
Overload sets are formed by [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1 General [expr.prim.id.general]")*s* naming functions and function templates and
|
||
by [*splice-expression*](expr.prim.splice#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]")*s* designating entities of the same kinds[.](#2.sentence-3)
|
||
|
||
â *end note*]
|
||
|
||
[*Example [1](#example-1)*:
|
||
|
||
[ð](#:overloading,example_of)
|
||
|
||
double abs(double);int abs(int);
|
||
|
||
abs(1); // calls abs(int); abs(1.0); // calls abs(double); â *end example*]
|