//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>&)
{ }
我確實想實現operator<<
爲Internal
但,當我嘗試使用該運營商的呼叫從External
一個問題:它並不認爲這是運營商在這個運營商這個類的定義下申報,而且似乎沒有宣佈上述這個類定義這種操作方式。如何申報經營者<<對內部類
爲什麼ISN」 t「內部」合格嗎? –