当前位置: 代码迷 >> 综合 >> c++结构体一些写法
  详细解决方案

c++结构体一些写法

热度:7   发布时间:2024-02-01 23:42:59.0

(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;
}
};

  相关解决方案