I have the following code:
struct simple
{
simple (int a1, int a2) : member1(a1), member2(a2) {}
int member1;
int member2;
};
std::ofstream &
On the line :
f << "label: " << s;
Because the first call to operator<<
returns a std::ostream &
, the second fails to compile : the left operand to the operator is not of type std::ofstream
anymore and your overload is not found.
You should really use the second signature, as I see no reason for restricting your type to be outputted to std::ofstream
.