Ok so a little bit of background, I am trying to write a boggle solver, I had everything working until I tried to implement a Binary Search Tree for storing the words found on the board, when I tried to do this I got the following errors:
Error 1 error C2146: syntax error : missing ';' before identifier 'foundWord' line 24
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int line 24
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int line 24
boggle.h
#pragma once
#include<iostream>
#include<string>
#include<ctime>
#include<fstream>
#include"HashTable.h"
#include"SLL.h"
#include"BST.h"
using namespace std;
class boggle
{
struct Piece
{
char letter;
bool isUsed;
};
Piece boggleBoard[3][3];
HashTable WordListHT; //Calls HashTable
string soFar;
BST foundWord; // Creating a Binary Search tree for any found words
public:
boggle(void);
~boggle(void);
void LoadWordList(string name);
void CreateBoard();
void PrintBoard();
void WordSearch();
void WordSearch(int i, int j); // overloaded function for recursive call during search
};
copy of BST.h
#pragma once
#include<iostream>
#include<string>
#include"boggle.h"
using namespace std;
class BST
{
struct Node
{
string element;
Node* left;
Node* right;
};
Node* root;
public:
BST(void);
~BST(void);
void Insert(string data);
void PreOrder();
void PreOrder(Node* n);
};
and just to make sure I'm not missing anything stupid
BST.cpp
#include "BST.h"
BST::BST(void)
{
root = 0;
}
BST::~BST(void)
{
}
void BST::Insert(string data)
{
Node* n = new Node;
n->element = data;
n->left = 0;
n->right = 0;
// Special case if root == 0
if(root == 0)
{
root = n;
return;
}
// Creating a new node for insertion
//Create tmp to traverse nodes
Node* tmp = root;
// Use a while loop to determine where the node is inserted
while(tmp) // While tmp has some value besides NULL(0)
{
// if data less then tmp->element then go left
if(data < tmp->element)
{
// if tmp->right == 0 then insert here
if(tmp->left == 0)
{
tmp->left = n;
return;
}
// else procede to next node
else
{
tmp = tmp->left;
}
}
// else go left
else
{
// if tmp->right == 0 then insert here
if(tmp->right == 0)
{
tmp->right = n;
return;
}
// else procede to next node
else
{
tmp = tmp->right;
}
}
}
}
The Binary Search Tree was originally intended to take ints, but for this project need it to take strings.