This is my code...

#include <iostream>
#include <fstream>
#include <vector>
using namespace std;

bool searchVect(vector<int>, int);


int main()
{
	bool answer;
	int value;
	vector<int> vect = {13579,  26791,  26792,  33445,  55555,
						62483,  77777,  79422,  85647,  93121};
	
	cout << "Enter the number to determine if there is a winner. \n";
	cin >> value;

	answer = searchVect(vect, value);

	cout << "The answer of whether it was found is " << answer << endl;

	return 0;
}

bool searchVect(vector<int> vect, int v) 
{
	bool answer = false;

	answer = binary_search(vect.begin(), vect.end(), v);
	return answer;
}

What i don't understand is how come the binary_search isn't recognized inside the function. If i need to pass something to the function then what? Also it possibe to make the function above a template with the class vector inside the function already being a template, so that both templates work in unison, the function and the vector class template that was passed to the function?

You're missing a header file where the definition of binary_search is
add #include <algorithm>

vector<int> vect = {13579,  26791,  26792,  33445,  55555,
						62483,  77777,  79422,  85647,  93121};
	
}

What i don't understand is how come the binary_search isn't recognized inside the function. If i need to pass something to the function then what? Also it possibe to make the function above a template with the class vector inside the function already being a template, so that both templates work in unison, the function and the vector class template that was passed to the function?

Regardless of anything else, you can't initialize a vector like this, so the program won't compile anyway. Initialize the vector correctly so that the program compiles and see if you have better luck with the binary search.

Well all be damn. Its not in my book. Looks like i need to get a book on the STL to continue.

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.