Journal #4942

Posted 16 years ago2008-03-13 05:24:02 UTC
void busqueda_lin2(const vector<int> &v, int x,int &i,bool &b)
{
int tam = v.size();
int i =0;
bool b = false;
while (i<tam and not b) {
if (v[i]==x) b=true;
else i++;
}

}

Compiling error:

declaration of 'int &i' shadows a parameter
declaration of 'bool &b' shadows a parameter

Why???

1 Comment

Commented 16 years ago2008-03-13 06:21:26 UTC Comment #58591
don't know, but it may be because you are redeclaring b and i in the function, when they already should be declared to be included in the function. also, i don't think that bool's and int's can be used as objects.

You must log in to post a comment. You can login or register a new account.