Can anyone tell me why I'm getting build errors on the actual function heading and the line under it (**) saying "type bool is unexpected" and that I'm missing a ; before {? I've looked and can't find anything.
Also, I get this error but there is no line 80 and all my braces match up (I think):
pa2-q1.cpp(80) : fatal error C1075: end of file found before the left brace '{' at '.\pa2-q1.cpp(17)' was matched
Any help is appreciated! :confused:
#include <iostream>
#include <conio.h>
using namespace std;
const int MAX_ITEMS=10;
bool Bsearch (int , int , int , int, int&);
int main ()
{
int chart[MAX_ITEMS]= {2,6,9,14,23,65,92,96,99,100};
int find, start, end, tms;
tms=0;
bool cont=1;
cout<<"This programs looks for a number in a preset list."<<endl;
do{
cout<<"Enter a number (no decimals), starting location for search, and ending location "<<
"(start & end between 0 & "<<MAX_ITEMS-1<<" , inclusive)."<<endl;
cin>>find>>start>>end;
if ((start<0||start>MAX_ITEMS-1) ||(end<0||end>MAX_ITEMS-1))
{
cout<<"Either the starting or ending location are outside of parameters."<<endl;
break;
}
else if (start>=end)
{
cout<<"Starting location must be less than ending location."<<endl;
break;
}
else
{
//bool found=0
if (Bsearch(chart[MAX_ITEMS],find,start,end,tms))
cout<<"Your number was found in the list after "<<tms<<" passes."<<endl;
else
cout<<"Your number was not found in the list after "<<tms<<" passes."<<endl;
cout<<"Search for another number? Enter 1 for Yes or 0 for No: ";
cin>>cont;
} while (cont);
_getch();
return 0;
}
**bool Bsearch (int chart[], int find, int start, int end, int& tms)
**{
if (start>end)
return false;
else
{
int mid=(start+end)/2;
if (chart[mid]==find)
return true;
else if (find<chart[mid])
{
tms++;
return Bsearch (chart[MAX_ITEMS], find, start, mid-1, tms);
}
else
{
tms++;
return Bsearch (chart[MAX_ITEMS], find, mid+1, end, tms);
}
}
}