C++ error help

eigen

Diamond Member
Nov 19, 2003
4,000
1
0
So I wrote ths program to solve the 8-queens problem ( how can you put 8 queens on the board at once without any of them being able to attack any other).Any way I have good heuristics, as I Have traced throught the program and watched it solve the problem.It also compiles fine on my laptop with using M$ Visual C++ and on a Linux/GNU server using gcc.

My question is this. I have a function that gets called from main its called attack(). If the attack() (placing the queens on the board) fails it returns a value , (result =-1) ,if it works it returns a value of (result = 8). Now the attack() function returns to the main.If main() receives -1 it iterates the process again until it works, if it recieves an 8 the program halts and thats that.The problem is when the flow goes back into main() from attack() I can see that it is in main but when the the result,either -1 or 8, is refrenced an error occurs.I have no clue as to why it is doing this.I have tried returning the result value using pass-by value;pass-by refrence, pass-by pointer etc.

Has anyone else had a similar problem ever....?

and no this is not a homework problem.If it were I would have asked for help with something other that what will proably turn out to be a small syntax error.

I will email anyone my source code if they think they can help.
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Shoot me the code. I will try and look at it this evening.
Use the email address in the profile.