0

I naturally included

#include <iostream>
using namespace std;

but the following overloading not works

friend ostream& operator<<(ostream& stream, mystruct& x);

just if I included std::

friend std::ostream& operator<<(std::ostream& stream, mystruct& x);

Why it is necessary?

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by merse
0

>> Why it is necessary?

Well, it shouldn't be... I tried the code separately on both GCC and minGW compilers, and both compiled well and didn't complain...

Try adding the statement

using std::ostream;

and try again...

0

using std::ostream; solves the problem
however I also use MinGW!?

0

Sorry it was my fault, the using namespace was at wrong place

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.