Programmation c++

kamalditta -  
 kamalditta -
Bonjour,
j ai ecris un petit programme en c++ qui doit m'afficher un tableau que g rempli mais une drole d'erreur saffiche'unsigned reference to table ::n' svp aider moi a resoudre ce probleme
voici mon programme

#include <iostream>

using namespace std;


class Table
{
static int n;
int *e;// elements of the table!!
public:
Table(int a)
{
n=a;
}


int operator[](int i)
{
if(i<0||i>=n)
cerr<<"the size of your table is not respected!"<<endl;

else
{return e[i];}
}

//implementation d'operateurs
friend Table operator+(const Table& s1, const Table& s2)
{
Table s(s1.n);
if(s1.n!=s2.n)
cerr<<"impossible d'additionner deux tableau de taille differente"<<endl;
else{
for(int i=0;i<n;i++)
s.e[i]=s1.e[i]+s2.e[i];
};
return s;
}

Table(const Table& z)
{
n=z.n;
e=z.e;
}

void affiche()
{
for(int i=0;i<n;i++)
cout<<e[i]<<endl;

}
void remplir()
{
for(int i=0;i<n;i++)
e[i]=5;
}

};

int main()
{
Table t(5);

t.remplir();
t.affiche();
}

1 réponse

kamalditta
 
kelkinnn pourai t il m'aider pliiiz
0