Guest User

ListaPachetti.h

a guest
Feb 6th, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. #ifndef _VETTORE_REGALI_H
  2. #define _VETTORE_REGALI_H
  3. #include <iostream>
  4. #include "Pacchetto.h"
  5. #include "ClasseEccezioneOutOfRange.h"
  6.  
  7. using namespace std;
  8.  
  9. typedef PacchettoRegalo A;
  10.  
  11. class ListaPacchetti {
  12.             friend ostream & operator<<(ostream&, const ListaPacchetti &);
  13.             friend istream & operator>>(istream&, ListaPacchetti &);
  14.             private:
  15.                static int count; //anche se non esplicitamente richiesta nella traccia, uso un contatore per il vettore dinamico
  16.                A * V;
  17.                int Nelem;
  18.             public:
  19.                explicit ListaPacchetti(const int = 10); //per impedire la conversione implicita del riempimento del vettore
  20.                ListaPacchetti (const int, const A &);
  21.                ListaPacchetti (const ListaPacchetti &);
  22.                int get_Nelem() const {return Nelem;}
  23.                static int get_count() {return count;}
  24.                A & operator[](int);          
  25.                const A & operator[](int) const; //Necessaria poiché si fa riferimento a un vettore costante
  26.                class EccezioneOutOfRange {};
  27.                static A & Access(int index) throw(EccezioneOutOfRange);            
  28.                ~ListaPacchetti() {count--; delete [] V;}
  29.                };
  30.                
  31. #endif
Advertisement
Add Comment
Please, Sign In to add comment