- Example

Let's have a look at an example of dependent names in this lesson.

We'll cover the following...

Example: Template Lookup

Press + to interact
// templateLookup.cpp
#include <iostream>
void g(double) { std::cout << "g(double)\n"; }
template<class T>
struct S {
void f() const {
g(1); // non-dependent
}
};
void g(int) { std::cout << "g(int)\n"; }
int main(){
g(1); // calls g(int)
S<int> s;
s.f(); // calls g(double)
}
...