Quiz 15
Anonymous
2,120 views
#description: This is called koenig lookup or argument dependent name lookup. In this case, the namespace 'standards' is searched for a function 'foo' because its argument 'ds' is defined in that namespace. For function 'bar', no additional namespaces are searched and the name is not found. More details are in 3.4.2.
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
#include <iostream>
namespace standards
{
struct datastructure
{
};
void foo(const datastructure& ds)
{
}
void bar()
{
}
}
int main(int argc, char** argv)
{
standards::datastructure ds;
foo(ds);
bar();
return 0;
}
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.