Nov 7, 2010 at 6:36am UTC
Here is the code:
#include <iostream>
using namespace std;
int first;
int goal;
int Tempor_ans=0;
char Tempor_op[7];
char op[20][10];
int No_of_solu=0;
int replace=0;
void isGoal(int operand_no ,int first,int array[] ,int sequ,int goal)
{
if (operand_no>1)
{
Tempor_ans=first+array[sequ];
Tempor_op[sequ-1]='+';
if (operand_no>2)
{
isGoal(operand_no,Tempor_ans,array,sequ+1,goal);
if(Tempor_ans==goal&&operand_no==2)
{
for(int i=0;i<replace ;i++)
op[No_of_solu][i]=Tempor_op[i];
No_of_solu++;
}
}
}
that the complier have a error said the first declared as `int replace'
and
`replace' was not declared inside the function
also use of `replace' is ambiguous
what's wrong with the code????
Nov 7, 2010 at 9:01am UTC
There is a standard library function replace
and you have a variable called replace
so compiler can't decide which one you want to use. One way to solve is to remove using namespace std;
from your code or just simply rename the variable.
Nov 7, 2010 at 3:14pm UTC
This is a great example of the many reasons why using namespace xxx;
is evil.