Well whatever I'm doing I'm probably doing it wrong I know that.
What I was trying to do was rework on my resize function in my matrix class so it can resize both matrices of type <int> and of type <dlist> with a single function call. So I been reading up on template specialization. But am fairly new and still don't understand it all and can't get any of the code i've written so far to compile without taking the resize function out of the class and declaring it globally. that part i've been able to accomplish, or at least the prototypes anyway.
dlist (and zlist as well) both have a function with the same name: resize.
oh heck I'm having too much difficulty explaining it.
here is my matrix.cpp relevant code:
1 2 3 4 5 6 7
|
template <class itemType>
void matrix<itemType>::resize(int newRows, int newCols)
{
myRows = newRows;
myCols = newCols;
return;
}
|
But for a NxN sudoku, I need to also maintain a matrix of possibile candidates for each space in the main grid, hence my dlist class, which is a list of N bits.
So ideally what I would like to do is override the resize function in the event that the calling object is of type dlist or of type zlist to something like:
1 2 3 4 5 6 7 8 9 10
|
template <class itemType>
void matrix<itemType>::resize(int newRows, int newCols)
{
myRows = newRows;
myCols = newCols;
for (int i = 0; i < myRows; ++i)
for (int j = 0; j < myCols; ++j)
myMatrix(i, j).resize(myRows);
return;
}
|
But only execute this function for matrices of types that have a resize function defined, because it wouln't make any sense to resize an int.