Visual c++ ';操作员<<';必须返回值吗?

Visual c++ ';操作员<<';必须返回值吗?,visual-c++,compiler-errors,Visual C++,Compiler Errors,获取编译器错误c4716('operator代码中没有任何值的return。正如错误所述,您的operator//Friend函数用于将塔打印到流 奥斯特雷姆算子 // Friend function to print the towers to stream ostream& operator<<(ostream& stream, const TheGame& game) { stream << "Tower #0:"

获取编译器错误c4716('operator代码中没有任何值的
return
。正如错误所述,您的
operator
//Friend函数用于将塔打印到流
奥斯特雷姆算子
// Friend function to print the towers to stream
ostream& operator<<(ostream& stream, const TheGame& game) {
stream
    << "Tower #0:" << game.towers[0] << endl
    << "Tower #1:" << game.towers[1] << endl
    << "Tower #2:" << game.towers[2] << endl
    ;
}
// Friend function to print the towers to stream
ostream& operator<<(ostream& stream, const TheGame& game) {
    return stream
        << "Tower #0:" << game.towers[0] << endl
        << "Tower #1:" << game.towers[1] << endl
        << "Tower #2:" << game.towers[2] << endl
        ;
}