I am working on a sudoku solver that finds all solutions. To obtain multiple solutions I am using two objects. The first class is "Cell" to store the value, possible values, if it is solved, etc. The second class "Puzzle" is derived from class "Cell" and is a 2D array of "Cell" objects. I plan to copy the Puzzle object into a new Puzzle object and push one onto a stack to solve later for another solution.
I believe the error is in my Puzzle class constructor for private member board[9]9] (this is the 2D array of Cell objects). board is initialized in Puzzle.h as
Puzzle.h
1 2 3 4 5 6 7 8 9
|
#include "Cell.h"
class Puzzle : public Cell
{
public:
Puzzle(void);
private:
Cell board[9][9];
};//end clas Puzzle
|
Cell.h
1 2 3 4 5
|
class Cell
{
public:
Cell(int row, int col, int input_value);
}//end Cell.h
|
Puzzle.cpp
1 2 3 4 5 6 7
|
#include "Cell.h"
#include "Puzzle.h"
using namespace std;
Puzzle::Puzzle(void) : Cell(0,0,0)
{
}//end constructor
|
**My member functions were left out for brevity.
I receive the following error messages.
1 2 3 4 5 6 7 8
|
Puzzle.cpp: In constructor ‘Puzzle::Puzzle()’:
Puzzle.cpp:13:34: error: no matching function for call to ‘Cell::Cell()’
Puzzle.cpp:13:34: note: candidates are:
In file included from Puzzle.cpp:7:0:
Cell.h:8:2: note: Cell::Cell(int, int, int)
Cell.h:8:2: note: candidate expects 3 arguments, 0 provided
Cell.h:5:7: note: Cell::Cell(const Cell&)
Cell.h:5:7: note: candidate expects 1 argument, 0 provided
|
It seems to me that I gave the Cell constructor 3 arguments with Puzzle::Puzzle(void) : Cell(0,0,0)
I believe and I could be wrong that the problem occurs when I try to create a puzzle object in my main() program by declaring
Puzzle puzzle_board;
and the 81 cell objects try to be created but are somehow not initialized.
My questions:
How do I initialize all 81 Cell objects in board?
Is there a way to have the default constructor called when board is created?
I can post the whole files if needed.
Thank you for helping me out! I have been scouring the internet for advice but to no avail.