S
subramanian100in
Consider the code:
#include <iostream>
using namespace std;
int main( )
{
cout << "test string ";
cout.operator<<(10).operator<<(endl);
return 0;
}
This prints
test string 10
followed by a newline as expected.
However, in main( ), if I have
cout.operator<<("test string
").operator<<(endl).operator<<(10).operator<<(endl);
it prints
0x804897c
10
followed by a newline. It does not print test string but instead
prints its address.
I do not understand.
Does it mean that operator<<(const char *) is not a member function of
ostream ? If so why ?
Kindly explain.
Thanks
V.Subramanian
#include <iostream>
using namespace std;
int main( )
{
cout << "test string ";
cout.operator<<(10).operator<<(endl);
return 0;
}
This prints
test string 10
followed by a newline as expected.
However, in main( ), if I have
cout.operator<<("test string
").operator<<(endl).operator<<(10).operator<<(endl);
it prints
0x804897c
10
followed by a newline. It does not print test string but instead
prints its address.
I do not understand.
Does it mean that operator<<(const char *) is not a member function of
ostream ? If so why ?
Kindly explain.
Thanks
V.Subramanian