ho appena iniziato ad usare i template ma di nel manuale che uso sono trattati davvero poco: questo è il codice (l'ho messo tutto insieme senza dividerlo in moduli), mi da errore alla costruzione dell'oggetto, spero che qualcuno sia in grado di aiutarmi.
Grazie in anticipo
codice:
#include <iostream>

template<class T> class matrix{
public: 
    void setlines(const int& );
    void setcolumns(const int&);
    void printmat()const;
    int howmanyvar(const T&) const;
    T& insert(const int&, const int& );
    T read(const int&, const int&)const; 
    void SetAllVar0();
    matrix(const int&,const int&,const T** const);
    ~matrix();
private:
    int righe;
    int colonne;
    T**  matrice;
};
    
using namespace std;




int main() {
    int matrice[2][2]={{15,56},{45,19}};
    matrix<int> miamat(2,2, matrice);
    int a=0;
    a=miamat.read(0,0);
    cout<<a;
    return 0;
}






template<class T> T& matrix<T>::insert(const int& rig, const int& col){
   return *((*(matrice+rig))+col);
}
template<class T> T matrix<T>::read(const int& rig, const int& col)const{
    return *((*(matrice+rig))+col);
}


template<class T> void matrix<T>::SetAllVar0(){
    for (int y=0; y<righe; y++)
        for (int i=0; i<colonne; i++)
            *((*(matrice+y))+i)=0;
}


template<class T> matrix<T>::matrix(const int& rig,const int& col, const T** const mat){
    righe=rig; colonne= col;
    matrice = new int*[righe];
    for (int i=0; i<righe; i++) *(matrice+i)= new int[col];
    for (int y=0; y<righe; y++)
        for (int i=0; i<colonne; i++)
            *((*(matrice+y))+i)=*((*(mat+y))+i);
        
    
    }




template<class T> matrix<T>::~matrix(){
    for (int i=0; i<righe; i++) delete [] *(matrice+i);
    delete [] matrice;
}




template<class T> int matrix<T>::howmanyvar(const T& var)const{
    int count=0;
    for (int i=0; i<righe; i++){
        for (int y=0; y<colonne; y++)
            if (var==*((*(matrice+i))+y))count++;
    }
    return count;
}


template<class T> void matrix<T>::setlines(const int& rig){
    righe= rig; 
    matrice= new int*[righe];
    //for (int i=0; i<righe; i++) delete [] *(matrice+i);
    //delete [] matrice;
    for (int i=0; i<righe; i++) *(matrice+i)= new int[colonne];
}


template<class T> void matrix<T>::setcolumns(const int& col){
    colonne= col; 
    //for (int i=0; i<righe; i++) delete [] *(matrice+i);
    for (int i=0; i<righe; i++) *(matrice+i)= new int[col];
}