2015-07-19 40 views
2

我使用Visual Studio 2013,編程C++和具有以下屬性的基類:Visual C++ if語句。斷點將目前尚未受到打擊

ref class AI 
{ 

... 

protected: 

    /// <summary> 
    /// Exit found flag. False if exit is yet to be found, true if it already was. 
    /// </summary> 
    bool exitFound; 

... 

} 

在派生類中,我有以下代碼:

void AI_II::analyze(void) 
{ 

... 

     this->exitFound = true; 

     if (this->exitFound) 
     { 
      if (this->distFront->lastTile == EXIT){...} 
      else if (this->distDown->lastTile == EXIT){...} 
      else if (this->distBack->lastTile == EXIT){...} 
      else if (this->distUp->lastTile == EXIT){...} 
     } 

... 

} 

我不知道如何,但在運行或調試時,總是會跳過if (this->exitFound)語句。調試時,我得到「斷點不會被打...」的信息。

我已經嘗試清理解決方案,但目前爲止沒有成功。任何人都可以幫我找到問題所在?

+0

你確定你沒有調試發佈(優化)構建? http://stackoverflow.com/questions/23348983/explicitly-initialize-dword-to-1-but-debugger-shows-wildly-out-of-range-value/23349047#23349047 – PaulMcKenzie

回答

2

在Visual Studio [Properties] - [Build]選項卡中選擇並選中[Define DEBUG constant]和[Define TRACE constant]。在[高級]選項卡中勾選[調試信息]設置爲[完整]。

+2

謝謝你的建議!這只是一個編譯器優化問題。 – marceloatg