От: | igna | ||
Дата: | 16.07.06 08:23 | ||
Оценка: | 3 (2) |
14.6.3 Non-dependent names [temp.nondep]
1 Non-dependent names used in a template definition are found using the usual name lookup and bound at the
point they are used. [Example:
void g(double); void h(); template<class T> class Z { public: void f() { g(1); // calls g(double) h++; // ill-formed: cannot increment function; // this could be diagnosed either here or // at the point of instantiation } }; void g(int); // not in scope at the point of the template // definition, not considered for the call g(1)
—end example]
#include <iostream>
void g(double) { std::cout << "void g(double);\n"; }
template<class T> class Z {
public:
void f() { g(1); }
};
void g(int) { std::cout << "void g(int);\n"; }
int main()
{
Z<int> z;
z.f();
}