#include<iostream> using namespace std; class OpoverClass { friend ostream& operator<<(ostream&,const OpoverClass&); friend istream& operator>>(istream&,OpoverClass&); public: OpoverClass operator+ (const OpoverClass&) const; OpoverClass operator* (const OpoverClass&) const; OpoverClass (int i=0,int j=0){a=i;b=j;};
int a; int b; };
ostream& operator<<(ostream& osObject,const OpoverClass& right) { osObject<<"("<<right.a<<","<<right.b<<")"; return osObject; }
istream& operator>>(istream& isObject,OpoverClass& right) { isObject>>right.a>>right.b; return isObject; }
OpoverClass OpoverClass::operator *(const OpoverClass& right) const { OpoverClass temp; temp.a=a*right.a; temp.b=b*right.b; return temp; }
OpoverClass OpoverClass::operator +(const OpoverClass& right) const { OpoverClass temp; temp.a=a+right.a; temp.b=b+right.b; return temp; }
int main() { OpoverClass u(23,46); OpoverClass v; cout<<"u="<<u<<endl; cout<<"Enter two integers:"; cin>>v; cout<<endl; cout<<"u+v="<<u+v<<endl; cout<<"u*v="<<u*v<<endl; return 0; }
请大家帮忙看下错误:D:\c++\vdgfd\vfdf.cpp(51) : error C2593: 'operator <<' is ambiguous D:\c++\vdgfd\vfdf.cpp(53) : error C2593: 'operator >>' is ambiguous D:\c++\vdgfd\vfdf.cpp(55) : error C2593: 'operator <<' is ambiguous D:\c++\vdgfd\vfdf.cpp(56) : error C2593: 'operator <<' is ambiguous Error executing cl.exe.
vfdf.obj - 4 error(s), 0 warning(s)