I have a function like this:
int find_string ( string *url){
if(*url.find() != string::npos){
[...]
}
[...]
}
And call it this way:
find_string(&url);
But I got the following compiling error:
request for member ‘find’ in ‘url’, which is of non-class type ‘std::string*’
Why this happen and, most importantly, how can I fix this? (When there was no pointer, it was working)
*url.find()is equivalent to*(url.find())when what you actually want is(*url).find(). Better yet you should be usingurl->find()instead.The reason for this is the dereference (
*) operator has lower precedence than the element selection (.) operator.