Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
MyClassクラスを作成し、a、b、c の 3 つのデータ メンバーを持つクラスを呼び出したいと思います。次に、多くのMyClassオブジェクトを a に配置std::Vector<MyClass>し、データ メンバーに従ってベクターを並べ替えたいと考えています。
MyClass
std::Vector<MyClass>
STLを使用してこれを行うエレガントな方法はありますか? 車輪の再発明はしたくありませんでしたし、これが最初ではないはずです。Java では、Comparator.
Comparator
比較関数をコーディングし、STL セットを使用して、次のような比較実装をコーディングできます。
bool operator<(MyClass other) const { return (expression); }