MULTIPLICATION MATRICIELLE ENCHAINEE

yann_lo_san Messages postés 1137 Date d'inscription lundi 17 novembre 2003 Statut Membre Dernière intervention 23 janvier 2016 - 26 sept. 2006 à 21:38
yann_lo_san Messages postés 1137 Date d'inscription lundi 17 novembre 2003 Statut Membre Dernière intervention 23 janvier 2016 - 26 sept. 2006 à 21:38
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.

https://codes-sources.commentcamarche.net/source/39701-multiplication-matricielle-enchainee

yann_lo_san Messages postés 1137 Date d'inscription lundi 17 novembre 2003 Statut Membre Dernière intervention 23 janvier 2016 26
26 sept. 2006 à 21:38
C'est très utile, je te met 8.
Mais cela aurait été plus clair avec une classe matrice avec opérateurs enchainables.
Voici une spécification quui pourrait marcher.

#pragma once
#include

class Matrice
{
int** m_t;
int m_nbrLignes;
int m_nbrColonnes;
public:
Matrice(int=3, int=3);
Matrice(const Matrice&);
~Matrice();
friend Matrice operator * (int, const Matrice&);
Matrice operator + (const Matrice&) const;
const Matrice& oprator = (const Matrice&);
friend istream& operator >> (istream&, Matrice&);
friend ostream& operator << (ostream&, const Matrice&);
};

// Attrention au constructeur de copie !
Matrice::Matrice(const Matrice& matCopie)
{
m_nbrLignes = matCopie.m_nbrLignes;
m_nbrColonnes = matCopie.m_nbrColonnes;
m_t = new int*[m_nbrLignes];

for(int i=0; i<m_nbrLignes; i++)
{
m_t[i] = new int[m_nbrColonnes];
for(int j=0; j<m_nbrColonnes; j++)
m_t[i][j] = matCopie.m_t[i][j];
}
}

// pour le reste c'est du tout cuit.
Rejoignez-nous