正在加载图片...
重載插入、提取运算符的实现 15:06:48 include <iostream> # include“ Complex.h using namespace std ostream& operator<<(ostream& os, const Complex& c)( oS < C real < +(< C image < )i return os istream& operator>>(istream& is, Complex& c)( is >>c real >>cimage return 1S; #include <iostream> include“ Complex.h” using namespace std void maino( Complex cl, c2 cin > c1 >>c2. cout < cl <<endl < c2 < end115:06:48 重载插入、提取运算符的实现 #include <iostream> #include “Complex.h” using namespace std; ostream& operator<<(ostream& os,const Complex& c){ os << c.real << "+ (" << c.image << ")i"; return os; } istream& operator>> (istream& is,Complex& c){ is >> c.real >> c.image; return is; } #include <iostream> #include “Complex.h” using namespace std; void main(){ Complex c1,c2; cin >> c1 >> c2; cout << c1 <<endl << c2 << endl; }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有