I don't actually need any coding help, however, in my coursework to create a sudoku solver, I have to create something "defined as an array of nine CellGroup
objects, linking to a total of 81 Cell objects" for the row, column and 'block'.
I am not sure how to do this? Maybe something like linked list or something? I don't know.
I think they mean linking in a more abstract sense, that you should be able to get to/access the 81 Cell objects somehow by using the array of 9 CellGroups. You don't want to use a linked list here. Arrays are all you need.
The description says you should have an array of 9 CellGroups. Exactly how you represent a CellGroup is up to you. It could simply be an array (an array with 9 elements or possibly a 3x3 2D array), or maybe a struct/class object containing such an array.
I've created an array of pointers in a cellgroup class, Cell *cellPointers[9];
I created 3 more arrays for the row, column and block.
So my row array, has 9 arrays, each with 9 pointers in it. My question is, I need to populate the board with a text file, but how do I put all the 81 numbers into my row arrays, if you understand what I mean.
I'm not sure why you need pointers to the cells. That creates memory mnagement issues and creates the potential for memory leaks. I think you will find it easier to treat the cellgroup as a 3x3 array of cells.
If you really want to use pointers, cellgroup's constructor will need to allocate 9 Cells and assign those pointers to the respective cellPointers.
Don't forget that cellgroup's destructor will need to delete those pointers.
Am I suppose to be putting constructors anywhere? I guess I need to add some to the Cellgroup class, and probably the cell, but i'm not sure whatsoever.
Ahh, I see what you're doing with your Sudoku class. You have separate Cellgroups for the 9 rows, the 9 columns and the 9 blocks. I think that's making things more complicated. When you update a cell, you're going to have to update it in 3 places, actually 4 places if you include board[9][9]. I think it's much easier to keep one image of the state of the board, which is what I suggested in my earlier post.
And yes, Cell should have a constructor to initialize value and cellFixed. Do not assume that because you're always initializing from a file, you can do this at the time you read each cell from the file. If you create a temporary cell anywhere (such as pushing onto a vector) you're going to want it initialized.