Next greater integer in circular array

in this code, i am getting an error that “reference to greater is ambigous” why is this so. what is wrong ??

#include
#include
#include
using namespace std;

void greater(vector &v,int n){
vector ans(n);
stack s;
for(int i=2*n-1;i>=0;i–){
while(s.empty()==false && v[i%n]>=v[s.top()]){
s.pop();
}
ans[i%n]=(s.empty() ?-1:v[s.top()]);
s.push(i%n);
}
for(int i=0;i<ans.size();i++){
cout<<ans[i];
}
}

int main() {

vector<int> v;
int n;
cin>>n;
v.reserve(n);
for(int i=0;i<n;i++){
	int data;
	cin>>data;
	v.push_back(data);
}

greater(v,n);
return 0;

}

@neelmani98
There are two solutions to your problem.

  1. add scope operator “::” i.e ::greater(v, n);
  2. Change the name of the function and keep it something else because greater is a keyword. so C++ gets confused which greater are you talking about.