OK this should do it:
Code:
#include <iostream>
using namespace std;
class X
{
char ch;
public:
X(char chch): ch(chch) {}
friend ostream& operator<<(ostream& os, const X& x)
{
return os << x.ch;
}
friend istream& operator>>(istream& is, const X& x);
};
istream& operator>>(istream& is, const X& x)
{
return is >> x.ch;
}
int main() {}
I'm only given the warning message (VC++ Express) if the operator>> friend function is defined outside of the class body and if the second parameter is declared as const. If I take the const out, no warning message. However, if I define the function inside the body of the class like I have with operator<<, I'm given no warning even with the const. Warnings are set at level 4.