操作符重载

操作流重载

cout是一种ostream类型

1
2
3
4
operator <<(ostream &os,const complex& x){
return os<<'C'<<real(x)<<','<<imag(x)<<')';
}
cout<<conj(c1)//调用函数operator <<(cout,c1)