Question about if() Statement

//-------------------------------------------------------
case WM_KEYDOWN: // Key down
vkKeys[wParam] = true;
switch (wParam)
{
case VK_SHIFT: // Shift key
nVirtKey = GetKeyState(VK_LSHIFT); // Get state of left
// shift
if (nVirtKey & SHIFTED) // If left shift
vkKeys[VK_LSHIFT] = true;
nVirtKey = GetKeyState(VK_RSHIFT); // Get state of right
// shift
if (nVirtKey & SHIFTED) // If right shift
vkKeys[VK_RSHIFT] = true;
break;
case VK_CONTROL: // Control key
nVirtKey = GetKeyState(VK_LCONTROL);
if (nVirtKey & SHIFTED) // If left control
vkKeys[VK_LCONTROL] = true;
nVirtKey = GetKeyState(VK_RCONTROL);
//----------------------------------------------------------------

I am confused about some things like if(!done) or if(nVirtKey & SHIFTED). that's the meaning? I just know this kind of instance :
int a=1;
int b=2;
if(a<b)
........;
what's the meaning a if() without operator in it?
Last edited on
There are operators, if you look closer.

"!done" means "done != 0".
"a & b" performs binary and.
Note that if's don't really require operators.
"a < b" returns a boolean true/false value.
"a & b" returns an integer type, later evaluated to bool (nonzero is true, zero is false).
if(true) code is always executed.
if(false) code is never executed.
Ok, now I understand it. Think you
Topic archived. No new replies allowed.