The problem is that you define it inside the class, which
a) means the second argument is implicit (this
) and
b) it will not do what you want it do, namely extend std::ostream
.
You have to define it as a free function:
class A { /* ... */ };
std::ostream& operator<<(std::ostream&, const A& a);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…