|
stream |
c方式的格式化 |
灵活性 |
+ |
- |
安全性 |
+ |
- |
效率 |
- |
+ |
模拟实现:
cpp_ostream& operator <<(int i)
{
char buffer[100];
sprintf(buffer, "%d", i);
m_str += buffer;
return *this;
}
} cpp_cout;
cpp_cout << i++ << i++ << i++;
cout << cpp_cout.m_str << endl;
cout代码位置:/usr/include/c++/<libstdc++ 版本号>/ostream