Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Proizvod.h"
- Proizvod::Proizvod() {
- }
- Proizvod::Proizvod(string n, double c, int b) {
- this->naziv = n;
- this->cena = c;
- this->brKom = b;
- }
- Proizvod::Proizvod(const Proizvod& p) {
- this->naziv = p.naziv;
- this->cena = p.cena;
- this->brKom = p.brKom;
- }
- Proizvod& Proizvod::operator--() {
- --this->brKom;
- return *this;
- }
- Proizvod& Proizvod::operator--(int) {
- this->brKom--;
- return *this;
- }
- bool Proizvod::operator<(Proizvod& p) {
- return this->brKom*this->cena < p.brKom * p.cena;
- }
- istream& operator>>(istream& in, Proizvod& p) {
- cout << "unesite naziv proizvoda: ";
- in >> p.naziv;
- cout << "unesite cenu jednog komada proizvoda " << p.naziv << ": ";
- in >> p.cena;
- cout << "unesite koliko " << p.naziv << " je trenutno na stranju: ";
- in >> p.brKom;
- return in;
- }
- ostream& operator<<(ostream& out, Proizvod& p) {
- out << p.naziv << " po ceni od: " << p.cena << ", na stanju raspolozivo: " << p.brKom << endl;
- return out;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement