河南成教 / 面向对象程序设计
15[分析题]
#include ”iostream.h”class three{ int x,y,z; public: three(int a,int b,int c){ x=a;y=b;z=c;} friend ostream &operator<<(ostream &output, three ob); };ostream &operator<<(ostream &output, three ob){ output<<ob.x<<’,’<<ob.z<<’,’<<ob.y<<endl; return output;}main(){ three obj1(10,20,30); cout<<obj; three obj2(50,40,100);cout<<obj2; }
15[分析题]
#include ”iostream.h”class three{ int x,y,z; public: three(int a,int b,int c){ x=a;y=b;z=c;} friend ostream &operator<<(ostream &output, three ob); };ostream &operator<<(ostream &output, three ob){ output<<ob.x<<’,’<<ob.z<<’,’<<ob.y<<endl; return output;}main(){ three obj1(10,20,30); cout<<obj; three obj2(50,40,100);cout<<obj2; }
参考答案:
佳题速递: