-
February 20th, 2013, 02:26 PM
#1
calling another function within a function isnot working
I have two functions bool check_key(string cKey, string eKey) and bool check_digit(char digit1, char digit2), and I have declared both of them globally (is this the right terminology?) right after the "using namespace std;" and right before the "int main(){".
In the first one, I called the second one . But it is giving me the error: "no match for call to `(std::string) (int&)' ".
I am not sure how to fix this.
Code:
bool check_key(string cKey, string eKey)
{
if(cKey!="" && eKey=="") return false;
if(cKey=="" && eKey=="") return true;
if(cKey=="" && eKey!="") return true;
if(cKey.length()!= eKey.length()) return false;
bool flag=true;
bool one_digit_wrong=false;
for(int i=0;i<cKey.length();i++)
{
if(cKey[i]!=eKey[i])
{
if(!one_digit_wrong)
{
flag=flag && check_digit(cKey[i],eKey(i)); //ERROR OCCURS HERE
one_digit_wrong=true;
}
else return false;
}
}
return flag;
}
bool check_digit(char digit1, char digit2)
{
int num = atoi(&digit1);
string allowed = allowed_errors[num-1];
for(int i=0; i<allowed.length();i++)
{
if(digit2==allowed[i]) return true;
}
return false;
}
-
February 20th, 2013, 02:32 PM
#2
Re: calling another function within a function isnot working
flag=flag && check_digit(cKey[i],eKey(i));
See anything different between the first argument and the second?
-
February 20th, 2013, 02:32 PM
#3
Re: calling another function within a function isnot working
Never mind! found the error!! I needed to change the () into a [] in eKey(i), because eKey is not a function .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|