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.

Recommended Answers

All 3 Replies

Just to check, what happens when you comment out line 24?

Just to check, what happens when you comment out line 24?

long and short answer

when I comment out BST foundWord; the compiler errors out on my function call line in Boggle.cpp, comment out that line and it runs with no errors

snippet of code from Boggle.cpp

void boggle::WordSearch(int i, int j)
{
	if(!boggleBoard[i][j].isUsed)
	{
		soFar += boggleBoard[i][j].letter;
		boggleBoard[i][j].isUsed = true;
		if(WordListHT.Find(soFar))
		{
			//foundWord.Insert(soFar);
			cout << soFar << ", ";
		}
		if (!WordListHT.FindPartial(soFar))
		{
			soFar = soFar.substr(0, soFar.size() - 1); // might be length instead of size
			boggleBoard[i][j].isUsed = false;
			return;
		}

Found the error...

Had to remove #include"boggle.h" from BST.h

now on to other issues, thanks for looking

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.