Advertisement
MeehoweCK

Untitled

Jul 11th, 2023
525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class TablicaInt
  6. {
  7.     int* dane;
  8.     unsigned rozmiar;
  9. public:
  10.     TablicaInt();
  11.     TablicaInt(unsigned size);
  12.     ~TablicaInt();
  13.     unsigned get_rozmiar() const;
  14.     int dodaj_element(int wartosc);
  15.     void wypisz_calosc() const;
  16. };
  17.  
  18. TablicaInt::TablicaInt() : dane(nullptr), rozmiar(0)
  19. {
  20.     cout << "Utworzono pusta tablice.\n";
  21. }
  22.  
  23. TablicaInt::TablicaInt(unsigned size) : rozmiar(size), dane(new int[size])
  24. {
  25.     for (unsigned i = 0; i < rozmiar; ++i)
  26.         dane[i] = 0;
  27.     cout << "Utworzono tablice o rozmiarze " << size << ".\n";
  28. }
  29.  
  30. TablicaInt::~TablicaInt()
  31. {
  32.     delete[] dane;
  33.     cout << "Zniszczono tablice.\n";
  34. }
  35.  
  36. int main()
  37. {
  38.  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement