H
Hans De Winter
Hi,
I am really puzzled why my compiler does not accept the following code:-
--- CODE STARTS HERE ---
#include <iostream>
using namespace std;
class Foo
{
};
class Writer: public ostream
{
public:
Writer() : ostream(cout.rdbuf()) {}
Writer& operator<<(Foo&) {cout << "Hi"; return *this;}
};
int main(int argc, const char* argv[])
{
Foo f;
Writer w;
w << "Test"; // OK
w << f; // OK
w << '\t'; // OK
w << endl; // Not OK: Compiler complains about <unknown type>
return 0;
}
--- CODE STOPS HERE ---
Any hints? Many thanks in advance!
Hans
I am really puzzled why my compiler does not accept the following code:-
--- CODE STARTS HERE ---
#include <iostream>
using namespace std;
class Foo
{
};
class Writer: public ostream
{
public:
Writer() : ostream(cout.rdbuf()) {}
Writer& operator<<(Foo&) {cout << "Hi"; return *this;}
};
int main(int argc, const char* argv[])
{
Foo f;
Writer w;
w << "Test"; // OK
w << f; // OK
w << '\t'; // OK
w << endl; // Not OK: Compiler complains about <unknown type>
return 0;
}
--- CODE STOPS HERE ---
Any hints? Many thanks in advance!
Hans