I am trying to make a bool function which finds a value in an array and return true if it finds the value and or false if it doesn't, but I keep getting the error "No matching function to call to". Here's my code:
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <array>
using namespace std;
bool exists(int v[],int k)
{
if(find(begin(v),end(v),k)!=end(v))
return true;
else
return false;
}
int main()
{
int v[5]={1,2,3,4,5};
int k=4;
if(exists(v,k))
cout<<"yes";
else cout<<"no";
return 0;
}
What can I do to make it work?