Advertisement
MeehoweCK

Untitled

May 3rd, 2021
801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Cena
  6. {
  7.     friend double operator+(Cena&, double);
  8.     friend double operator-(Cena&, double);
  9.     double PLN;
  10. public:
  11.     Cena(double);
  12. };
  13.  
  14. double operator+(Cena& cena, double kwota)
  15. {
  16.     kwota *= 1.1;
  17.     cena.PLN += kwota;
  18.     return cena.PLN;
  19. }
  20.  
  21. double operator-(Cena& cena, double kwota)
  22. {
  23.     kwota * 0.95;
  24.     cena.PLN -= kwota;
  25.     if(cena.PLN < 0)
  26.         cena.PLN = 0;
  27.     return cena.PLN;
  28. }
  29.  
  30. Cena::Cena(double ile) : PLN(ile) {}
  31.  
  32. int main()
  33. {
  34.     Cena cena(20);
  35.     cout << cena + 15 << endl;
  36.     cout << cena - 12 << endl;
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement