set容器中使用结构体

来源:互联网 发布:淘宝被恶意投诉卖假货 编辑:程序博客网 时间:2024/06/06 16:41

在使用set容器时,如果需要用到结构体时。需要重载  "<"

struct   NodeInfo

{

           float    point ;

           bool    operator<(const NodeInfo & dpoint)const

           {

                 return dpoint.point < point;

           }

}

如果没有"<"的重载,会出现以下错误:

error C2784: “bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)”: 未能从“const QuestionAnswserInfoST”为“const std::_Tree<_Traits> &”推导 模板 参数

原创粉丝点击