template matrice générique
bonjour, je voudrais me mettre au template afin d'avoir un code un peu plus générique. Pour ce faire je suis partis sur les matrices.
Matrice.hh
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#ifndef MATRICE_HH
#define MATRICE_HH
namespace maths {
template<typename T> class Matrice {
private:
int n, m;
T** tab;
public:
Matrice();
Matrice(int, int);
~Matrice();
void affiche();
};
}
#endif |
Matrice.cc
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
|
#include "Matrice.hh"
#include<iostream>
namespace maths {
template<typename T>
Matrice<T>::Matrice() {
// ...
}
template<typename T>
Matrice<T>::Matrice(int x, int y):n(x), m(y) {
// ...
}
template<typename T>
Matrice<T>::~Matrice() {
// ...
}
template<typename T>
void Matrice<T>::affiche() {
// ...
}
} |
main.cc
Code:
1 2 3 4 5 6 7 8 9
|
#include "Matrice.hh"
#include<iostream>
using namespace maths;
int main() {
Matrice<double> a(2, 2);
} |
Avec ce petit main(), j'ai des erreurs du type "undefined references..." pour le constructeur appelé.
Please, de l'aide.
HELP!!