对<<运算符重载,让他能和cout一起显示对象内容。
显示值可以使用show(),但是使用cout<<更方便。
ostream类对该运算符进行了重载,将其转换成输出工具。
cout就是一个ostream的对象,他可以自动识别所有的c++基本类型。这是因为每种类型ostream他都包含了相应的重载operator<<定义。
void ostream& operator<< (ostream &os, const Time &t)
{
os << t.hours <<;
}
对<<运算符重载,让他能和cout一起显示对象内容。
显示值可以使用show(),但是使用cout<<更方便。
ostream类对该运算符进行了重载,将其转换成输出工具。
cout就是一个ostream的对象,他可以自动识别所有的c++基本类型。这是因为每种类型ostream他都包含了相应的重载operator<<定义。
void ostream& operator<< (ostream &os, const Time &t)
{
os << t.hours <<;
}