The overloading of extraction operator(>>) is giving the following errors. The insertion (<<)operator is working within the code. It looks like there are some header files missing to be included? or there are other errors which I can't see.
Code:
Declaration:
#include <iostream>
.
.
class x{
friend ostream &operator<<(ostream &, const product &); <--- Work fine
friend istream &operator>>(istream &, product &); <---- Giving the errors shown below
public:
}
Definition:
istream &operator >>(ostream &input, product &p)
{
.........
}
Compiler Error:
------------------Configuration: useProduct - Win32 Debug--------------------
Compiling...
product.cpp
error C2143: syntax error : missing ';' before '&'
error C2433: 'istream' : 'friend' not permitted on data declarations
error C2501: 'istream' : missing storage-class or type specifiers
error C2244: 'istream' : unable to resolve function overload
error C2061: syntax error : identifier 'istream'
error C2501: '>>' : missing storage-class or type specifiers
error C2805: binary 'operator >>' has too few parameters
Error executing cl.exe.
product.obj - 7 error(s), 0 warning(s)
Thanks.