EDITED:
I want to use a custom compare function written inside a class like this code.
class cl{
public:
string st;
int *pos;
cl(string s){
st=s;
pos=new int[s.size()];
for (int i = 0; i < (int)s.size(); i++){
pos[i]=i;
}
}
static int compare(int c1,int c2 ){
return st[c1]<st[c2];
}
void function_using_custom_compare_function(){
sort(pos,pos+st.size(),compare);
}
};
but i cant compile this code.
how to use the compare function inside a class ?
make it static.
thanks for your reply. I have edited the code which I actually need. now making the compare function static does not solve the problem.
code or code
thanks