Computer Science Canada

Using member functions inside boolean statements.

Author:  abcdefghijklmnopqrstuvwxy [ Thu Jan 25, 2007 3:11 am ]
Post subject:  Using member functions inside boolean statements.

Hey. Is there anything I should know about boolean statements and using functions inside them?

Look at this code:

code:

void handle_tac_events(std::vector<Tac>& vTacs, std::vector<Tac>::iterator iter, std::vector<Tac>::iterator end, int& x, int& y, Board& board)
{
  int result;
  for (; iter != end ; ++iter)
  {
    result = iter->handleEvents(x, y, board);
    if (result == MOVED_A_TAC )
    { 
      vTacs.push_back(Tac(iter->getColor(), board));
      return;
    }
    else if (result == CLICKED_A_TAC)
    {
      return;
    }
  }
  return;
}


If i substitute "iter->handleEvents(x, y, board)" with result in the if statements why does it not ever return true? Whereas with result in its place it works fine...


: