fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class baton
  6. {
  7. public:
  8. string nazwa;
  9. int cena;
  10. baton(int,string);
  11. bool operator < (baton&);
  12. };
  13.  
  14. int main(void)
  15. {
  16. baton a(3,"Smaczny"),b(1,"Niedobry");
  17. cout<<"Tanszy baton jest "<<(a<b?a.nazwa:b.nazwa)<<'\n';
  18. return 0;
  19. }
  20.  
  21. bool baton::operator <(baton& inny)
  22. {
  23. return cena < inny.cena;
  24. }
  25.  
  26. baton::baton(int x,string y):cena(x),nazwa(y)
  27. {}
  28.  
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
Tanszy baton jest Niedobry