重载流操纵器操作符

时间:2016-10-28 07:48:01

标签: stream overloading std ostream manipulators

您好我正在尝试重载运算符<<挂钩

stream << std::endl;

避免&#39; \ n&#39;如果我不需要输出,请附加。 我alredy重载:

std::ostream& operator<< (std::ostream& (*pf)(std::ostream&))
std::ostream& operator<< (std::ios& (*pf)(std::ios&))
std::ostream& operator<< (std::ios_base& (*pf)(std::ios_base&))

但是电话总是在basic_ostream

结束
_Myt& __CLR_OR_THIS_CALL operator<<(_Myt& (__cdecl *_Pfn)(_Myt&))
{// call basic_ostream manipulator
    _DEBUG_POINTER(_Pfn);
    return ((*_Pfn)(*this));
}

1 个答案:

答案 0 :(得分:0)

自己找到解决方案

问题是其他重载运算符返回了std :: ostream&amp;所以无法调用重载函数。