Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * File: kontener.h
- * Author: Marcin
- */
- #ifndef KONTENER_H
- #define KONTENER_H
- #include <memory.h>
- template <typename TYP>
- class Kontener {
- protected:
- // Domyślny rozmiar kontenera
- static const unsigned int DOMYSLNY_ROZMIAR = 0;
- // Wskaźnik na właściowy kontener oraz jego rozmiar
- TYP *kontener;
- unsigned int rozmiar;
- public:
- // Konstruktory i destruktory
- // Domyślny konstruktor
- Kontener();
- // Konstruktor z parametrami
- // explicit - dzięki temu konstruktor działa tylko jako konstruktor zwykły,
- // a nie też jako konwertujący. Dzięki temu niemożliwe stanie się np. przypisanie:
- // Kontener tablica;
- // tablica = 5; // Stworzyłby wtedy 5 - elementowy kontener
- explicit Kontener(unsigned int podany_rozmiar);
- // Konstruktor kopiujący
- Kontener(const Kontener& orig);
- // Wirtualny destruktor
- virtual ~Kontener();
- // Metody
- unsigned int pobierz_rozmiar() const; // Pobiera rozmiar kontenera
- TYP pobierz_elem(unsigned int index); // Pobiera element o podanym indeksie
- bool dodaj_elem(TYP wartosc); // Dodaje element do kontenera
- bool modyfikuj_elem(unsigned int index, TYP wartosc); // Zmienia wskazany element
- bool usun_elem(unsigned int index); // Usuwa element z kontenera
- bool zamien_elem(TYP& a, TYP& b); // Zamienia dwa elementy miejscami
- bool zmien_rozm(unsigned int nowy_rozmiar); // Zmienia rozmiar kontenera
- // Przeciążone operatory
- // Przeciążony operator przypisania
- Kontener& operator=(const Kontener& nowa);
- // Przeciążony operator indeksowania
- TYP& operator[](unsigned index);
- };
- //
- #endif /* KONTENER_H */
Advertisement
Add Comment
Please, Sign In to add comment