ostream deferencing operator <<
c++, cout, operators
Solution
`operator<<` is implemented as a member function for only a limited number of types. For other types, it's implemented as a global overload like:
std::ostream &operator<<(std::ostream &os, T const &t) {
// write the data here
}
The syntax you used will only work with the overloads that are implemented as member functions, not as globals.
Problem
Why does this work well: ``` cout << "foo"; ``` While this doesn't? ``` (&cout)->operator<<("foo"); ``` It works fine with numeric values so I guess it's something related to override. (I'm using the MS Visual C++ compiler.)