//--------------------------------------------------------------------------- // dyna3.cpp // Ohjelmalla demonstroidaan dynaamista taulukkoa josa alkiotkin luodaan // Ei järkeä inteillä // Vesa Lappalainen 5.3.2001 // #include #include class cTaulukko { int max_koko; int lkm; int **alkiot; public: cTaulukko(int ikoko) : max_koko(ikoko), lkm(0) { alkiot = new int*[max_koko]; } ~cTaulukko() { poista_alkiot(); delete [] alkiot; } void poista_alkiot(); void lisaa(int luku) { if ( lkm >= max_koko ) return; alkiot[lkm] = new int(luku); // "copy constructor" lkm++; } void tulosta() const; }; void cTaulukko::tulosta() const { int i; for (i=0; i