#include "wyjatki.h" //#include #ifndef _WEKTOR_H #define _WEKTOR_H const int max_rozmiar = 20; template class Wektor { protected: int ile; int rozmiar; T* elementy; public: Wektor(int r=max_rozmiar); Wektor(const Wektor &); T &operator[](int i); void Dodaj(const T&); void UsunOstatni(){ if(ile > 0) ile-- ; }; int Rozmiar(){return rozmiar; }; int IleElementow(){return ile; }; void Wyczysc(){ ile = 0;}; ~Wektor(){ delete [] elementy; }; // iterator (tu po prostu wskaznik) typedef T* iterator; T* begin(){ return elementy; }; T* end(){ return elementy+ile; }; }; template Wektor::Wektor(const Wektor &w) { ile = w.ile; elementy = new(std::nothrow) T[w.rozmiar]; if(elementy == 0) throw BrakPamieci(); for(int i=0;i T& Wektor::operator [](int ind) { if(ind <0 || ind >=ile) throw ZlyIndeksWektora(ind,"Niestety, to jest zly indeks\n"); return elementy[ind]; } template Wektor::Wektor(int r):rozmiar(r),ile(0) { if (r<0) throw Wyjatek("Rozmiar nie moze byc mienjszy od zera\n"); elementy = new(std::nothrow) T[rozmiar]; if(elementy == 0) throw BrakPamieci(); }; template void Wektor::Dodaj(const T& w) { if(ile == rozmiar) { rozmiar*=2; T *tmp = new(std::nothrow) T[rozmiar]; if(tmp==0) throw BrakPamieci(); for(int i=0;i