Home > Software engineering >  MFC displacement operator cannot be used properly
MFC displacement operator cannot be used properly

Time:12-11

Void CTEST: : OnButton4 ()
{
//TODO: Add your the control notification handler code here
/* the UpdateData (TRUE);
UINT I=(m_show & gt;> 1); */
int i=0;
I=(4 & gt;> 2);

}
After press Button4 button, could you tell me why I will always be equal to zero? Displacement calculation is what doesn't work?

CodePudding user response:

No way!
int i=0;
I=(4 & gt;> 2);
AfxDump & lt;

CodePudding user response:

Debug mode output, could be optimized away
 
Void CTEST: : OnButton4 ()
{
int i=0;
I=(4 & gt;> 2);
TRACE (_T (" 4 & gt;> 2=% d \ n "), I);
}


CodePudding user response:

refer to the second floor zgl7903 response:
debug mode output, could be optimized away
 
Void CTEST: : OnButton4 ()
{
int i=0;
I=(4 & gt;> 2);
TRACE (_T (" 4 & gt;> 2=% d \ n "), I);
}

Use your code is normal, excuse me, is there any way without trace can directly use the shift operators can get the result?

CodePudding user response:

The operation itself is no problem,
Just because there is no statement below, debug mode (disable optimization), after I=4 & gt;> 2, the code will stop to the end of braces and can't see the stack variables, here to add a statement or debug pointer hauling step, can see
In Release mode, because behind the variable is not used, so will be optimized away

  • Related