Simple question
-
// Creates a reference of the board then copies // the reference to a new board const CBoard& rConstBoard = *mpBoard; CBoard Board = rConstBoard; is this call rite? because it causing my whole function not to work properly. can any tell me whats the problem. here is my whole function if my question information is insufficient... // Searches for the best computer move on the board int CComputer::CheckForMoves(int Depth, int Alpha, int Beta, int& Row, int& Col) { // Check if the Entered Depth is greater than the Maximum depth ASSERT(Depth >= MAXDEPTH); // Creates a reference of the board then copies // the reference to a new board const CBoard& rConstBoard = *mpBoard; <-- the problem CBoard Board = rConstBoard; Row = Col = 1; return 0; } And i wanted to return both Row and Col but it wont do that... i have debugged 15X wid the debugger and i still can find my mistake. can anyone tell me what i am doing wrong??? :( :( :( john
-
// Creates a reference of the board then copies // the reference to a new board const CBoard& rConstBoard = *mpBoard; CBoard Board = rConstBoard; is this call rite? because it causing my whole function not to work properly. can any tell me whats the problem. here is my whole function if my question information is insufficient... // Searches for the best computer move on the board int CComputer::CheckForMoves(int Depth, int Alpha, int Beta, int& Row, int& Col) { // Check if the Entered Depth is greater than the Maximum depth ASSERT(Depth >= MAXDEPTH); // Creates a reference of the board then copies // the reference to a new board const CBoard& rConstBoard = *mpBoard; <-- the problem CBoard Board = rConstBoard; Row = Col = 1; return 0; } And i wanted to return both Row and Col but it wont do that... i have debugged 15X wid the debugger and i still can find my mistake. can anyone tell me what i am doing wrong??? :( :( :( john
Why don't you just do this: CBoard Board = *mpBoard; // Assuming mpBoard has been properly instantiated. What makes you think you need a reference to CBoard? I mean, you've got a pointer to a board, than a reference to the same board and than a local instantiation of the same board. Looks a little convoluted to me. "There's a slew of slip 'twixt cup and lip"
-
Why don't you just do this: CBoard Board = *mpBoard; // Assuming mpBoard has been properly instantiated. What makes you think you need a reference to CBoard? I mean, you've got a pointer to a board, than a reference to the same board and than a local instantiation of the same board. Looks a little convoluted to me. "There's a slew of slip 'twixt cup and lip"
that worked but i still cant figure out the bug in my function. it returns both the row and column but it wont set the value. here is where i call the previous function... // Handles all the moves done by the computer void CChildView::ComputerMove() { // Set to default values int row = 0, col = 0; // Check for a possible move mpComputer->CheckForMoves(MAXDEPTH,Lose,Win,row,col); <-- this returns // both the row and column but the following function wont work // though the row and column is 1... mpComputer->SetMove(row,col); <-- wont work... Invalidate(); } when i comment out this: CBoard Board = *mpBoard; the whole function works just fine.... can anyone help me :( well, anways, thank you for your help... in advance :)
-
that worked but i still cant figure out the bug in my function. it returns both the row and column but it wont set the value. here is where i call the previous function... // Handles all the moves done by the computer void CChildView::ComputerMove() { // Set to default values int row = 0, col = 0; // Check for a possible move mpComputer->CheckForMoves(MAXDEPTH,Lose,Win,row,col); <-- this returns // both the row and column but the following function wont work // though the row and column is 1... mpComputer->SetMove(row,col); <-- wont work... Invalidate(); } when i comment out this: CBoard Board = *mpBoard; the whole function works just fine.... can anyone help me :( well, anways, thank you for your help... in advance :)
You have something wrong somewhere in your CBoard equal operator logic. The most likely culprit is that you are overwritting something in memory that something in SetMove does not like. Debug into CBoard& operator=( CBoard& ); "There's a slew of slip 'twixt cup and lip"
-
You have something wrong somewhere in your CBoard equal operator logic. The most likely culprit is that you are overwritting something in memory that something in SetMove does not like. Debug into CBoard& operator=( CBoard& ); "There's a slew of slip 'twixt cup and lip"
-
// Creates a reference of the board then copies // the reference to a new board const CBoard& rConstBoard = *mpBoard; CBoard Board = rConstBoard; is this call rite? because it causing my whole function not to work properly. can any tell me whats the problem. here is my whole function if my question information is insufficient... // Searches for the best computer move on the board int CComputer::CheckForMoves(int Depth, int Alpha, int Beta, int& Row, int& Col) { // Check if the Entered Depth is greater than the Maximum depth ASSERT(Depth >= MAXDEPTH); // Creates a reference of the board then copies // the reference to a new board const CBoard& rConstBoard = *mpBoard; <-- the problem CBoard Board = rConstBoard; Row = Col = 1; return 0; } And i wanted to return both Row and Col but it wont do that... i have debugged 15X wid the debugger and i still can find my mistake. can anyone tell me what i am doing wrong??? :( :( :( john