Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Cena
- {
- friend double operator+(Cena&, double);
- friend double operator-(Cena&, double);
- double PLN;
- public:
- Cena(double);
- };
- double operator+(Cena& cena, double kwota)
- {
- kwota *= 1.1;
- cena.PLN += kwota;
- return cena.PLN;
- }
- double operator-(Cena& cena, double kwota)
- {
- kwota * 0.95;
- cena.PLN -= kwota;
- if(cena.PLN < 0)
- cena.PLN = 0;
- return cena.PLN;
- }
- Cena::Cena(double ile) : PLN(ile) {}
- int main()
- {
- Cena cena(20);
- cout << cena + 15 << endl;
- cout << cena - 12 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement