//cannot declare operator<<(...) here:
//forward declarations:
class External;
template<class T, class Y>
class External::Internal;
template<class T, class Y>
std::ostream& operator<<(std::ostream& out, const External::Internal<T,Y>&);
class External
{
template<class T, class Y>
class Internal
{};
Internal data_;
void print() {
/*out is a std::ostream*/
out << data_;
}
};
template<class T, class Y>
std::ostream& operator<<(std::ostream& out, const External::Internal<T,Y>&)
{ }
I do want to implement operator<< for Internal but there is a problem when I try to use this operator call from External: It doesn’t see this operator when this operator is declared under the definition of this class, and there seems to be no way of declaring this operator above this class definition.
If you’re asking how to define
Internal<>::operator<<as a friend, then: