Question: #ifndef BOGGLE _ BOGGLE _ H #define BOGGLE _ BOGGLE _ H #include #include Dictionary.h using namespace std; const int BOARD _ SIZE =
#ifndef BOGGLEBOGGLEH
#define BOGGLEBOGGLEH
#include
#include "Dictionary.h
using namespace std;
const int BOARDSIZE ;
class BoardNotInitialized ;
class Boggle
public:
Boggle; load "dictionary.txt into dict
explicit Bogglestring filename; load filename into dict
void SetBoardstring boardBOARDSIZEBOARDSIZE;
void SolveBoardbool printBoard, ostream& output;
void SaveSolvestring filename; Saves all the words from the last solve.
Dictionary GetDictionary;
Dictionary WordsFound;
private:
Dictionary dict;
Dictionary wordsFound;
string boardBOARDSIZEBOARDSIZE;
int visitedBOARDSIZEBOARDSIZE;
void PrintBoardostream& output;
void SolveBoardHelperint row, int col, string currentWord;
;
#endif BOGGLEBOGGLEH
Boggle.cpp
#include "Dictionary.h
#include "Boggle.h
#include
#include
Your code here
Boggle::Boggle
Load the dictionary from the default file "dictionary.txt
dict.AddWordDictionarytxt;
Boggle::Bogglestring filename
Load the dictionary from the given filename
dict.AddWordDictionarytxt;
void Boggle::SetBoardstring inputBoardBOARDSIZEBOARDSIZE
for int i ; i BOARDSIZE; i
for int j ; j BOARDSIZE; j
boardij inputBoardij; Copy each entry
Initialize visited array to unvisited
memsetvisited sizeofvisited;
void Boggle::SolveBoardbool printBoard, ostream& output
wordsFound Dictionary; Reset found words
Iterate through each cell and start DFS
for int i ; i BOARDSIZE; i
for int j ; j BOARDSIZE; j
SolveBoardHelperi j;
Optionally print the board
if printBoard
PrintBoardoutput;
Output the found words
for const string& word : wordsFound.GetAllWords
output word endl;
This function is done.
Dictionary Boggle::GetDictionary
return dict;
This function is done.
Dictionary Boggle::WordsFound
return wordsFound;
void Boggle::SolveBoardHelperint row, int col, string currentWord
Base case: if the current position is out of bounds or already visited, return
if row row BOARDSIZE col col BOARDSIZE visitedrowcol
return;
Add the current letter to the word
currentWord boardrowcol;
Check if the current word is in the dictionary
if dictIsWordcurrentWord
wordsFound.AddWordcurrentWord; Add to found words
Mark the current cell as visited
visitedrowcol;
Explore all directions up down, left, right, diagonals
static int direction;
for int i ; i ; i
SolveBoardHelperrow directioni col directioni currentWord;
Backtrack: unmark the current cell
visitedrowcol;
void Boggle::PrintBoardostream& output
for int i ; i BOARDSIZE; i
for int j ; j BOARDSIZE; j
output boardij;
output endl;
void Boggle::SaveSolvestring filename
ofstream filefilename;
if fileisopen
for const string& word : wordsFound.GetAllWords
file word endl;
file.close;
error: forming reference to void
for const string& word : wordsFound.GetAllWords
error: forming reference to void
for const string& word : wordsFound.GetAllWords
I got an error because of these lines. please help me fix this to let this code working.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
