Erreur compilation ne recconnait pas classe comme type
Bonjour à tous, et d'abord merci de vous interresser à mon problème.
Alors voilà, je réalise un programme de matrice, dans lequel je surcharge des opérateurs, le compilateur m'indique une erreur : " expected constructor, destructor or type conversion before 'matrice' ".
Voici le ".h" :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| class matrice
{
protected :
T** mat;
int ligne,colonne;
public :
matrice(int _ligne, int _colonne);
matrice(const matrice& m);
//matrice &operator=(const matrice &m);
~matrice();
T getLigne();
T getColonne();
void setValeur(T _valeur, int _ligne, int _colonne);
T getValeur(int _ligne, int _colonne);
void LireFichier(string S);
void setLigne(int _ligne);
void setColonne(int _colonne);
matrice &operator+(const matrice &m);
matrice &operator-(const matrice &m);
friend ostream &operator<<(ostream & flux, matrice & m)
{
for(int i=0 ; i<(m.getLigne()) ; i++)
{
flux<<setw(3)<<'|';
for(int j=0 ; j<(m.getColonne()) ; j++) flux<<" "<<setw(3)<<m.getValeur(i,j);
flux<<" "<<setw(3)<<'|'<<endl;
}
return flux;
}
}; |
Voici le ".cpp" :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| template <typename T>
matrice matrice<T>::&operator+(const matrice &m) // ERREUR SUR CETTE LIGNE
{
if(ligne!=m.ligne || colonne!=m.colonne) return 0;
else
{
matrice resultat(ligne,colonne);
for(int i=0 ; i<ligne ; i++)
for(int j=0 ; j<colonne ; j++)
resultat[i][j]=mat[i][j]+m.mat[i][j];
}
return resultat;
}
template <typename T>
matrice matrice<T>::&operator-(const matrice &m) // ERREUR SUR CETTE LIGNE
{
if(ligne!=m.ligne || colonne!=m.colonne) return 0;
else
{
matrice resultat(ligne,colonne);
for(int i=0 ; i<ligne ; i++)
for(int j=0 ; j<colonne ; j++)
resultat[i][j]=mat[i][j]-m.mat[i][j];
}
return resultat;
} |