Hello everyone,

I'm working on a little exercise program that takes a matrix and a vector and performs algebra on them.

I'm using templates for both my 4x4 matrix class and my vector4 class.

My matrix4x4 class serves as a parent to specific types of matrices, like a translation matrix.

The program gives me an error when I instantiate a matrix4x4 class with no parameters and try to operate on it, even though I fill the values of the object in an empty constructor:

vector4<T> translateVector(const matrix4x4<T> matrix, const vector4<T> vector) { matrix4x4<T> tempMatrix(); for (int row = 0; row < MAX_LENGTH; ++row) { for (int column = 0; column < MAX_LENGTH; ++column) { tempMatrix[row][column] = (matrix[row][column] * vector[row]); //I get errors on this line and the one below newVector[row] += tempMatrix[row][column]; } } } //in matrix4x4.h: template <typename T> class matrix4x4 { public: T values[MAX_LENGTH][MAX_LENGTH]; matrix4x4() //when using this ctor, the compiler tells me I need to have a pointer to complete object type { for (int i = 0; i < MAX_LENGTH; i++) { for (int j = 0; j < MAX_LENGTH; j++) { values[i][j] = 0; } } }; T* operator[](int index) { assert (index > -1 && index < MAX_LENGTH); return values[index]; };

However, I fixed the problem by simply adding this ctor to the matrix4x4 class:

matrix4x4(T x) //this does exactly the same thing as empty ctor, just has a parameter { for (int i = 0; i < MAX_LENGTH; i++) { for (int j = 0; j < MAX_LENGTH; j++) { values[i][j] = 0; } } };

I feel like this is a bad patch to a larger problem I should address, but I'm not sure what that problem is or how to fix it.

Is it just a part of C++ to consider a templated object with an empty ctor to be "incomplete"?

**Edited by johnmarinelli, 03 August 2013 - 12:59 PM.**