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?

Recommended Answers

All 4 Replies

>> 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...

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

I'm intrigued. Please post a complete (small!) program that exhibits the problem.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.