class W
{
private:
long m_val1, m_val2;
public:
W(long& val1, long& val2):m_val1(val1), m_val2(val2) {}
template<class T>
friend std::ostream& operator<<(std::ostream& os, const T& w);
};
class X
{
private:
long m_val1, m_val2;
public:
X(const long& val1, long& val2):m_val1(val1), m_val2(val2) {}
template<class T>
friend std::ostream& operator<<(std::ostream& os, const T& x);
};
template<class T>
std::ostream& operator<<(std::ostream& os, const T& obj)
{
os << "m_val1: " << obj.m_val1 << ", m_val2: " << obj.m_val2 << endl;
}
这没用。谁能指出我想念什么?谢谢。此外,这会导致“错误 C2593:'操作 <<' 不明确”,无论“cout << “some string”;” 用来。