Hi all, for our lab exercises we were asked to overload both the << and >> operator for a class we made named Phone
From what our instructor has told us....
Up to that part I understand why he has said thatCode:friend ostream &operator<<(ostream & out, Phone &s); friend istream &operator>>(istream & in, Phone &s); //must be a non member function since it needs to access the private data
But I am confused as to why my compiler keeps saying
'opeartor' : references must be initialized
thus far I have only attempted the insertion operator, but I'm lost
It would be a big help if someone can direct me on how to do this?Code:istream &opeartor >>(istream &in, Phone &s) { in >> s; return in; }
e.g, in the driver we have
Please and thank youCode:Phone phone1; //should be able to do cout << phone1; cin >> phone1;



LinkBack URL
About LinkBacks



