Advertisement
programusy

zajonc kod pytel testy operator

Mar 16th, 2023
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class samochod{
  6. public:
  7. string marka;
  8. int pojemnosc;
  9. int ilosc_osob;
  10.  
  11. samochod(){
  12. cout << "Konstruktor 0 arg." << endl;
  13. }
  14.  
  15. samochod(string m, int v, int io){
  16. marka = m;
  17. pojemnosc = v;
  18. ilosc_osob = io;
  19.  
  20. cout << "Konstruktor 3 arg." << endl;
  21. }
  22. };
  23.  
  24. ostream &operator<<(ostream &out, samochod &smd){
  25. out << "Marka: " << smd.marka << " | Pojemnosc: " << smd.pojemnosc << "cm^3 | Ilosc: " << smd.ilosc_osob << "\n";
  26. return out;
  27. }
  28.  
  29. int main()
  30. {
  31. samochod s1("Audi", 2000, 5);
  32. samochod s2;
  33. s2.marka = "BMW";
  34. s2.pojemnosc = 2500;
  35. s2.ilosc_osob = 5;
  36.  
  37. cout << endl;
  38.  
  39. cout << s1;
  40. cout << s2;
  41. return 0;
  42. }
Tags: cpp Kod zajonc igor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement