ERROR: no match for 'operator<<" in 'std::cout

前端 未结 5 1302
孤城傲影
孤城傲影 2021-01-22 13:32

I realize this error is usually due to some syntax or type issues but I am not sure how to solve this problem. I think it may do with the type of findRt.

vector&         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-22 13:50

    For cout to be able to output your object you have to tell it how. One way is to overload the << operator:

    ostream& operator<<( ostream& os, const vector& vec ) {
        ...
        ... // here output to os the way you want it to
        os << ...
        return os;
    }
    

提交回复
热议问题