c++结构体一些写法
·
(go和c++学着学着就写混,特此记录)
struct Commodity { //商品类
long long id, score; //id和分数
Commodity(long long i, long long s) : id(i), score(s) {}
bool operator<(const Commodity& c) const { //重载小于运算符
return this->score != c.score ? this->score > c.score : this->id < c.id;
}
};
更多推荐
所有评论(0)