Maybe I should start over, combining this query with the previous one. Here is what I have so far (and it's actually starting to look like it's going to work):

Code:

template <class index_t, class scalar>
class matrix_base {
...
virtual matrix_base<index_t, scalar> * mat_mult(full_matrix<index_t, scalar>)=0;
virtual matrix_base<index_t, scalar> * mat_mult(sparse<index_t, scalar>)=0;
virtual matrix_base<index_t, scalar> * mat_mult(sparse_arr<index_t, scalar>)=0;
};
//a sparse matrix class:
template <class index_t, class scalar>
class sparse:public matrix_base<index_t, scalar> {
...
virtual matrix_base<index_t, scalar> * mat_mult(full_matrix<index_t, scalar>);
virtual matrix_base<index_t, scalar> * mat_mult(sparse<index_t, scalar>);
virtual matrix_base<index_t, scalar> * mat_mult(sparse_arr<index_t, scalar>);
};
//a class containing an array of sparse matrices:
template <class index_t, class scalar>
class sparse_arr:public matrix_base<index_t, scalar> {
...
virtual matrix_base<index_t, scalar> * mat_mult(full_matrix<index_t, scalar>);
virtual matrix_base<index_t, scalar> * mat_mult(sparse<index_t, scalar>);
virtual matrix_base<index_t, scalar> * mat_mult(sparse_arr<index_t, scalar>);
};
//full matrix class follows from the first two children...

The sparse array class presents a problem, however, since it actually has three template parameters:

Code:

template<index_t, scalar, matrix_t>
class sparse_array:public matrix_base<index_t, scalar> {
matrix_t *array_of_sparse_matrices;
int number_of_sparse_matrices;
...
};

So I need a way to squish the third template parameter down to the other two using sparse<index_t, scalar> for matrix_t . I need to do this before the other two classes can use the sparse array class since C++ doesn't allow templated virtual functions and I don't want the extra almost-useless template parameter dangling off the other two classes.

This is what I'm trying, but I don't know if it compiles yet because I need to update the makefile and get rid of all the other compilation errors first:

Code:

template <index_t, scalar>
class sparse_arr:public sparse_array<index_t, scalar, sparse<index_t, scalar>> {};