You need to take the function declarations:
Code:
void file();
bool getAWord( fstream& textFile, string& word );
void find(string& word );
and put them outside of the main() function. You can call functions in main(), but the function declarations have be put on their own, outside of any function.
So it should look like this:
Code:
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include "Bst.h"
//Function Declarations
void file();
bool getAWord( fstream& textFile, string& word );
void find(string& word );
int main()
{
BinarySearchTree wordSort;
ifstream fin;
string textFile, word;
int wordCount = 0;
//Call the functions here. They were declared above main,
//so the compiler knows what they look like when it gets
//to this point.
file();
if(getAWord(fin, word))
{
}
find("text);
}
//Function Definitions
void file()
{
\\CODE
}
bool getAWord( ifstream& textFile, string& word )
{
\\CODE
}
void find(string& word )
{
\\CODE
}
As for the void main() issue, putting void before main() was often done before C++ was standardized, so people who learned C++ before the standardization used both void main() and int main(). Compilers back then didn't complain about it because there was no official standard to follow. Each compiler behaved a little differently from the others. Now that there is a standard, main() is supposed to return an int so that the operating system knows whether there was an error in the program or not. Returning 0 means that there is no error, returning a non-zero value means that an error occurred. Other command line programs could then read the value being returned and respond appropriately.
My computer science professors taught us to use int main(), so when C++ was finally standardized I didn't have to change anything.
XCode 4 is enforcing the standard, so that's why it complains. Whatever other compilers you were using either are a bit lax in enforcing the standard or specifically allow void main() so pre-standard code doesn't break.
----------
mduser63 proposes an even more elegant solution than I did. My solution only works with a single file. When you write larger programs, and have to divide it up into multiple files, putting your declarations in header (.h) files allows you to call functions from another file without the compiler complaining. The compiler reads the header file first, knows which functions have been declared, so is able to compile calls to those functions, even if those functions are defined in another file.