Créer un type matrice avec des templates
Salut a tous
Je souhaiterai que vous m’aidiez a corriger ces lignes d'instructions:
J’aimerai dreer le type matrice avec des templates , mais je connais pas la syntaxe de " &operator[] " .
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| template <class TType > class ttype {
TType a[dim1][dim2];
public:ttype(void)
{ int i,j;
for(i=0; i<dim1; i++)
for(j=0; i<dim2; i++)
a[i][j]=0; }
TType &operator[][](int i,j); }
template <class TType> TType &ttype <TType>::operator[][](int i,j)
{ if ((i<0 || i>dim-1) & (j<0 || j>dim-1))
{ cout << " \n l'indice " << i <<"," <<j <<" est hors bornes \n" ; }
return a[i][j]; } |
Apres la compilation, voici les erreurs :
Compiling MAT.CPP:
Error MAT.CPP 15: Not an allowed type
Error MAT.CPP 15: Declaration syntax error
merci.