Une declaration de matrice (un des 4 constructeurs):
Matrice::Matrice(int nblig,int nbcol){
ligne=nblig;
col=nbcol;
matrice=new double*[ligne];
matrice[0]=new double[ligne*col]; //Allocation du tableau complet
for(int i=1;i<ligne;i++)
matrice[i]=matrice[i-1]+col;
memset(matrice[0],0,ligne*col*sizeof(double));
surcharge de << :
ostream& operator<<(ostream &flux,Matrice &m){
for(int i=0;i<m.ligne;i++){
flux << " ";
for(int j=0;j<m.col;j++)
flux << m.matrice[i][j] << " | ";
flux << endl;
}
flux << endl << endl;
return flux;
}
Y'a plus de probleme de segmentation fault mais il se passe des choses "bizarres". J'ai surchargé l'operateur * et lorsque j'effectue le calcul, ça marche "bizarrement". Je peux vous envoyer un imprime ecran si vous voulez.
Merci d'avance.
Message édité par Papy Brossard le 07-11-2004 à 18:53:13