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.)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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:The syntax you used will only work with the overloads that are implemented as member functions, not as globals.