If I am understanding your question correctly, you are trying to define Matrix as a template taking a row type and a column type, and then the rowType (and i assume also columnType) as templates of a matrix type. My big question is: where is the actual data? At some point, I presume this Matrix should actually break down to a structured group of ints, or doubles, or chars, or reverse iterators of pointers to bools, or something. Where is that?
your circularity seems to be a symptom of trying to make too much architecture. Figure out which class you want to actually store the data in, make the template parameter of that class the type of that data, then make the template parameter of all other related classes either the main class, or the data type as well. for example:
template <class DataType>
class Matrix{
//store the data in here: a DataType [], or vector<DataType>, or something
}
and:
template <class MatrixType>
class Row{
//has something which refers back to the original matrix of type MatrixType
}
or
template <class DataType>
class Row{
//has something which refers back to the original matrix of type Matrix<DataType>
}
I would suggest using the second of the above alternatives, as it makes is easier to refer to the Row class in the Matrix class, such as:
template <class DataType>
Row<DataType> Matrix::getRow(int index){
//return an instance of Row<DataType> containing the appropriate row
}