fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <set>
  4. using namespace std;
  5.  
  6. class Feat
  7. {
  8. public:
  9. Feat(int a){ _a = a;}
  10. int GetA() {return _a;}
  11. int _a;
  12. };
  13. struct lexical_compare {
  14. bool operator() (Feat a, Feat b) const {
  15. return a.GetA() < b.GetA();
  16. }
  17. };
  18.  
  19. int main() {
  20. set<Feat, lexical_compare> s;
  21.  
  22. s.insert(Feat(1));
  23. s.insert(Feat(10100));
  24. s.insert(Feat(18));
  25. s.insert(Feat(100));
  26.  
  27. for (Feat x : s)
  28. cout << x.GetA() << ' ';
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
1 18 100 10100