The output operator for built-in strings, i.e., the on taking a char const*
as argument, isn't a member of std::ostream
. The operator taking a char const*
is a non-member function would be called as
operator<< (std::cout, "Hello World");
There is, however, a member taking a void const*
which formats the value of the pointer using hex notation. This member is the best match when passing any pointer explicitly to a member operator<< ()
of std::ostream
.
Dereferencing the results of a the operator<<()
doesn't work: The operators return a std::ostream&
which doesn't have a unary operator*()
overloaded. If you meant to dereference the argument, you'd call it like so:
std:cout.operator<< (*"Hello World");
However, this would just derference the char const*
the string literal decays to, yielding an individual character H
. The character output function isn't a member function, either, while the output operators for integers are, i.e., it would print character value of H
. For a system using ASCII it would be 72
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…