about "friend name injection"

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top