1 最好打断点看看哦

2例子

 #include <iostream>

 using namespace std;

 class Complex2
{
public: Complex2(float x = , float y = )
:_x(x), _y(y){ }
void dis()
{
cout << "(" << _x << "," << _y << ")" << endl;
}
friend ostream & operator<<(ostream &os, const Complex2 &c);
friend istream & operator>>(istream &is, Complex2 &c); private:
float _x;
float _y;
}; ostream &operator<<(ostream &os, const Complex2 &c)
{
os << "(" << c._x << "," << c._y << ")";
return os;
} istream & operator>>(istream &is, Complex2 &c)
{
is >> c._x >> c._y;
return is;
}
int main()
{
Complex2 c(, );
cout << c << endl;
cin >> c;
cout << c << endl;
cin.get();
return ;
}
05-11 17:02