I tried to create generic stream class holder, but it seems like I cannot pass std::cout
to it, the code:
#include <iostream>
struct x
{
std::ostream &o;
x(std::ostream &o):o(o){}
};
int main()
{
x(std::cout);
x.o<<"Hi\n";
return 0;
}
fails when compiled as:
c++ str.cc -o str -std=c++11
str.cc: In function ‘int main()’:
str.cc:11:14: error: invalid use of qualified-name ‘std::cout’
str.cc:12:4: error: expected unqualified-id before ‘.’ token
Why?