> Why does the first statement output nonsense, but not the second. That
> is, why aren't the statements equivelement?
> #include <cmath>
> using namespace std;
> int main()
> cout.operator <<("sin(2)=").operator <<(sin(2)).operator <<(endl);
cout.operator << "sin(2)="; invokes the member function
ostream:perator<< (const void* param)
and not what you expected:
inline ostream operator<< (ostream& _O, const char *param)
The reason for this is that you explicitely ask for the member function
operator<<, but operator<< for char* is defined as static function (as
most other custom defined stream operators are). What you are seeing is
the address of the string.
> cout << "sin(2)=" << sin(2) << endl;
You should always stick to this invokation scheme.