Main.cc: In function ‘int bag(int, int)’: Main.cc:11:18: error: ‘n’ was not declared in this scope if(bag(ts-a[tn],n-1)==1){ ^ Main.cc:11:18: note: suggested alternative: ‘tn’ if(bag(ts-a[tn],n-1)==1){ ^ tn