-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path18.20.txt
More file actions
33 lines (29 loc) · 1.1 KB
/
18.20.txt
File metadata and controls
33 lines (29 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
namespace primerLib {
void compute();
void compute(const void *);
}
using primerLib::compute; // puts void compute(), and void compute(const void *) in the global scope
void compute(int);
void compute(double, double = 3.4);
void compute(char*, char* = 0);
// candidate functions:
// void compute() from primerLib
// void compute(const void *) from primerLib
// void compute(int)
// void compute(double, double = 3.4);
// void compute(char*, char* = 0);
void f()
{
compute(0);
// void compute() not viable
// void compute(const void *) viable: 0 can be converted to a pointer
// void compute(int) viable: exact match -> this is called
// void compute(double, double = 3.4) viable: through int to double conversion
// void compute(char*, char* = 0) viable: through pointer conversion
}
if the using declaration were located in main before the call to compute:
f would see only the global functions as candidates:
void compute(int), exact match
void compute(double, double = 3.4) double conversion
void compute(char*, char* = 0); pointer conversion
void compute(int) is called because it is an exact match