Problème héritage Matrice
Bonjour,
J'ai un problème avec l'héritage.
Voilà mon schéma :
Matrice.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:
typedef float *ligne;
ligne *matrice; // données de la matrice
int nbLig; // Nombre de lignes de la matrice
int nbCol; // Nombre de colonnes de la matrice
public:
int getNbColonnes() const;
int getNbLignes() const;
//les constructeurs/destructeur
Matrice(); // Constructeur par défaut
Matrice(int, int, double); // constructeur à 3 paramètres (nombre de lignes, nombre de collones, valeur de la matrice)
~Matrice(); // Destructeur
// Méthodes
const float get(const unsigned int &, const unsigned int &) const;
//les operateurs
Matrice operator*(const Matrice&);
//Matrice operator*(const Vecteur&);
float &operator()(int i, int j);
friend std::ostream& operator<<(std::ostream &, const Matrice&);
} |
Matrice.cpp
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Matrice::Matrice()
{
nbLig=4;
nbCol=4;
matrice = NULL;
}
Matrice::Matrice(int nl, int nc, double valeur)
{
nbLig = nl;
nbCol = nc;
matrice = new ligne[nbLig];
for(int i=0; i<nbLig; i ++)
{
matrice[i] = new float[nbCol];
for(int j=0; j<nbCol; j ++)
matrice[i][j] = valeur; //initialisation à 'valeur'
}
} |
MAtriceTrans.h
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| class MatriceTrans : public Matrice
{
protected:
float Tx; // Défaut de translation en x
float Ty; // Défaut de translation en x
float Tz; // Défaut de translation en x
public:
MatriceTrans();
MatriceTrans(float, float, float);
}; |
MatriceTrans.cpp
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| MatriceTrans::MatriceTrans(float Tx, float Ty, float Tz)
{
matrice[0][0]=1.0;
matrice[0][0]=1.0;
matrice[1][1]=1.0;
matrice[2][2]=1.0;
matrice[3][3]=1.0;
matrice[0][3]=Tx;
matrice[1][3]=Ty;
matrice[2][3]=Tz;
} |
Dans le constructeur de MatriceTrans, je ne peux pas accéder aux données de ma matrice (matrice[][]) alors que je l'ai mis en protected.
Je ne comprends pas quel est les problème :(
Merci de bien voulir m'aider.