#include <iostream.h>
class EnsEntiers {
  int * tab;      // adresse du tableau des valeurs
  int nmax ;      // nombre maximal de valeurs
  int card ;      // nombre effectif de valeurs

public :
  EnsEntiers (int n=20) {
    nmax=n;
    card=0;
    tab=new int[nmax];
  }

  EnsEntiers (EnsEntiers & E) {
    nmax=E.nmax;
    card=E.card;
    tab=new int[nmax];
    for (int i=0;i<card;i++) {
      tab[i]=E.tab[i];
    }
  }

  ~EnsEntiers () {
    delete []tab;
  }
  
  void  ajout(int n) {
    if (card<nmax) {
      tab[card++]=n;
    }
  }
  
  void affiche(){
    cout << "ensemble de "<< card <<" éléments ={";
    for (int i=0;i<card-1;i++) cout << tab[i]<<",";
    if (card!=0) cout <<tab[card-1]<<"}\n";
    else cout<<"}\n";
  }
  
  EnsEntiers &  operator=( EnsEntiers & E){
     if (&E==this) {
      return *this;
     }
     else {
      delete [] this->tab;
      this->card=E.card;
      this->nmax=E.nmax;
      this->tab=new int[nmax];
      for (int i=0;i<card;i++) this->tab[i]=E.tab[i];
      return *this;
    }
  }

    
  void operator>(int n) {
    if (card<nmax) {
      tab[card++]=n;
    }
  }    
};


int main(){
  EnsEntiers E1(10);
  EnsEntiers E2(5);
  EnsEntiers E4;
  E4.affiche();

  E1.ajout(2);E1.ajout(5);E1.ajout(3);E1.ajout(-5);
  E1.affiche();
  
  EnsEntiers E3=E1;
  E3.affiche();
  
  E2>4;E2>6;E2>8;E2>10;
  E2.affiche();

  
  E4=E2=E1;
  E2.affiche();
  E4.affiche();
}

