Overloading << operator ostream [closed]
Why doesn't the line below work?
#include <iostream>
std::ostream& operator <<( std::ostream& os, const char *c)
{
os << c; // why does this line doesn't work?
return os;
}
int main()
{
const char *c = "Hi";
std::cout << c;
}
The problem is std::ostream& operator <<( std::ostream& os, const char *c)
has already been overloaded in iostream.
精彩评论