在某本书上的一个例子,可我编译却不能通过,请教高手指点! #include<iostream> using namespace std;
class OpOverClass { friend ostream& operator<< (ostream&, const OpOverClass&); friend istream& operator>> (istream&, OpOverClass&);
public: OpOverClass (int i = 0, int j = 0);
private: 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 (int i, int j) { a = i; b = j; }
int main () { OpOverClass u (23, 45); OpOverClass v; cout << "u = " << u << endl;
cout << "Enter two integers: "; cin >> v; cout << "v = " << v << endl;
return 0; }