Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include "Proizvod.h"
  2.  
  3. Proizvod::Proizvod() {
  4.  
  5. }
  6.  
  7. Proizvod::Proizvod(string n, double c, int b) {
  8.     this->naziv = n;
  9.     this->cena = c;
  10.     this->brKom = b;
  11. }
  12.  
  13. Proizvod::Proizvod(const Proizvod& p) {
  14.     this->naziv = p.naziv;
  15.     this->cena = p.cena;
  16.     this->brKom = p.brKom;
  17. }
  18.  
  19. Proizvod& Proizvod::operator--() {
  20.     --this->brKom;
  21.     return *this;
  22. }
  23.  
  24. Proizvod& Proizvod::operator--(int) {
  25.     this->brKom--;
  26.     return *this;
  27. }
  28.  
  29. bool Proizvod::operator<(Proizvod& p) {
  30.     return this->brKom*this->cena < p.brKom * p.cena;
  31. }
  32.  
  33. istream& operator>>(istream& in, Proizvod& p) {
  34.     cout << "unesite naziv proizvoda: ";
  35.     in >> p.naziv;
  36.     cout << "unesite cenu jednog komada proizvoda " << p.naziv << ": ";
  37.     in >> p.cena;
  38.     cout << "unesite koliko " << p.naziv << " je trenutno na stranju: ";
  39.     in >> p.brKom;
  40.     return in;
  41. }
  42.  
  43. ostream& operator<<(ostream& out, Proizvod& p) {
  44.     out << p.naziv << " po ceni od: " << p.cena << ", na stanju raspolozivo: " << p.brKom << endl;
  45.     return out;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement