为什么以下行不起作用?
#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;
}
答案 0 :(得分:5)
问题是std::ostream& operator <<( std::ostream& os, const char *c)
已在iostream中重载。