Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Towar
- {
- private:
- string nazwa;
- string kod;
- double cena;
- double ilosc;
- public:
- // to jest konstruktor bo ma te sama nazwe co klasa !!!!
- Towar(string _nazwa, string _kod, double _cena, double _ilosc)
- {
- nazwa = _nazwa;
- kod = _kod;
- cena = _cena;
- ilosc = _ilosc;
- }
- void Wyswietl()
- {
- cout<<endl<<"Nazwa: "<<nazwa;
- cout<<endl<<"Kod: "<<kod;
- cout<<endl<<"Cena: "<<cena;
- cout<<endl<<"Ilosc: "<<ilosc;
- }
- };
- int main()
- {
- // tu automatycznie wywola sie konstruktor, w nawiasie musimy podac tyle
- // parametrow ile bylo parametrow w konstruktorze
- Towar t1("Pilka","P1",10,1);
- t1.Wyswietl();
- Towar t2("Buty","B1",11,2);
- t2.Wyswietl();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement