I am trying to declare a global function as a "friend" of a class:
namespace first
{
namespace second
{
namespace first
{
class Second
{
template <typename T> friend T ::first::FirstMethod();
};
}
}
}
When I compile this code under Visual C++ 2008 I get:
error C3254: 'first::second::first::Second' : class contains explicit override 'FirstMethod' but does not derive from an interface that contains the function declaration
error C2838: 'FirstMethod' : illegal qualified name in member declaration
If I use template <typename T> friend T first::FirstMethod();
instead I get:
error C2039: 'FirstMethod' : is not a member of 'first::second::first'
What is the appropriate way of declaring friend functions?