Z
zealotcat
Code from book <<C++ templates>>
----------------------------------------------------
template<typename T>
class C {
....
friend void f();
friend void f(C<T> const&);
....
};
void g (C<int>* p)
{
f(); // Is f() visible here?
f(*p); // Is f(C<int> const&) visible here?
}
----------------------------------------------------
Author say,"The trouble is that if friend declarations are visible in
the enclosing namespace, then instantiating a class template may make
visible the declaration of ordinary functions"?
What this means? Why "instantiating a class template may make visible
the declaration of ordinary functions"?
Thanks!
Alex
----------------------------------------------------
template<typename T>
class C {
....
friend void f();
friend void f(C<T> const&);
....
};
void g (C<int>* p)
{
f(); // Is f() visible here?
f(*p); // Is f(C<int> const&) visible here?
}
----------------------------------------------------
Author say,"The trouble is that if friend declarations are visible in
the enclosing namespace, then instantiating a class template may make
visible the declaration of ordinary functions"?
What this means? Why "instantiating a class template may make visible
the declaration of ordinary functions"?
Thanks!
Alex