As the title says, I'm having this really dumb problem when trying to overload the input operator>> with class objects when the overloaded function has already been friended. The output operator<< is perfectly fine, though; for some reason, it's only giving me an error about the input operator>> overloaded function.
#include <iostream>
void keep_window_open()
{
usingnamespace std;
cin.clear();
cout << "Please enter a character to exit\n";
char ch;
cin >> ch;
cin.ignore();
}
So what do I do? Is there something I've done wrong that I'm not noticing?
Edit: And doing it with the public access functions keeps producing the error that operator>> and an object of type double incompatible (which I know they shouldn't be).
Edit2: After overloading with a double-type object, I got this error:
1>ClassPoint.obj : error LNK2019: unresolved external symbol "class std::basic_istream<char,struct std::char_traits<char> > & __cdecl operator>>(class std::basic_istream<char,struct std::char_traits<char> > &,class Point const &)" (??5@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@std@@AEAV01@AEBVPoint@@@Z) referenced in function main
1>c:\users\osman\programming\visual studio 2015\Projects\ClassPoint\x64\Debug\ClassPoint.exe : fatal error LNK1120: 1 unresolved externals
I'm having this really dumb problem when trying to overload the input operator>> with class objects when the overloaded function has already been friended.
The problem is that you haven't created the implementation that matches your definition in the class.
In the class definition you have: friend std::istream& operator>> (std::istream &in, const Point &cPoint);
In main you have: std::istream& operator>> (std::istream &in, Point &cPoint)
Notice the difference in the second parameter.
By the way posting your compiler error messages would have made this problem easier to solve.