#include <iostream>
#include <vector>
using namespace std;
ostream& operator<<(ostream &out,vector<int>&src)
{
for (vector<int>::iterator it = src.begin(); it != src.end(); ++it)
{
out << *it << " ";
}
out << endl;
return out;
}
class Complex
{
private:
friend ostream& operator<<(ostream &out, Complex &c1); // ostream是系统自带cout的类型
int a;
int b;
public:
Complex(int a = 0, int b = 0)
{
this->a = a;
this->b = b;
}
void printCom()
{
cout<<a<<"+"<<b<<"i"<<endl;
}
};
ostream &operator<<(ostream &out, Complex &c1)
{
c1.printCom();
//cout<<c1.a<<"+"<<c1.b<<"i"<<endl;
return out;
}
int main()
{
vector<int> myVect;
for (int i = 0; i < 10; ++i)
{
myVect.push_back(i);
}
cout << myVect << endl;
Complex c(2,5);
cout << c << endl;
return 0;
}