Questions tagged [name-lookup]

Name lookup is the procedure by which a name, when encountered in a program, is associated with the declaration that introduced it.

For function names, name lookup can associate multiple declarations with the same name, and may obtain additional declarations from . Template argument deduction may also apply, and the set of declarations is passed to overload resolution, which selects the declaration that will be used. Member access rules, if applicable, are considered only after name lookup and overload resolution. For all other names (variables, namespaces, classes, etc), name lookup must produce a single declaration in order for the program to compile.

Unqualified name lookup

For an unqualified name, that is name that does not appear to the right of a scope resolution operator ::, name lookup examines the scopes as described below, until it finds at least one declaration of any kind, at which time the lookup stops and no further scopes are examined.

For the purpose of unqualified name lookup, all declarations from a namespace mentioned by a using directive are members of the namespace in which the using-directive appears.

303 questions
-1
votes
2 answers

distance calculation error in c++

#include #include #include using namespace std; int square(int a){ return a*a; } struct Point{ int x,y; }; int distance (const Point& a,const Point& b){ int k=(int)…
user466534
-1
votes
1 answer

Reference a symbol in a Go package without knowing if you are in that package?

Assume there is a function F in package A that some code I'm creating needs to call. How do I call it? If I'm Calling it from outside package A, then I uses A.F(...) and if I'm inside A I uses F(...). But what if Murphy prevents me from knowing…
BCS
  • 75,627
  • 68
  • 187
  • 294
-2
votes
1 answer

Why name lookup can't find std::swap when a base class has a swap function in C++?

I have a replica of what's inside my code #include using namespace std; class Parent { public: void swap(Parent*); }; class A : public Parent { public: void handle(); }; void A::handle() { long x = 1; …
Shady Atef
  • 2,121
  • 1
  • 22
  • 40
1 2 3
20
21