Hey, could anyone answer me this simple question? When I started learning C++ a few months ago I learned that when using a conditional statement that had &&, that this was the correct way to use it:
if ( x == 5 && y == 3)
But I've noticed that if I don't use just &, then the statements don't work correctly. For example (from my code):
WPAD_ScanPads();
u32 held = WPAD_ButtonsHeld(0);
if (held & WPAD_BUTTON_HOME)
{exit_menu();}
else if (held & WPAD_BUTTON_A)
{WLToggle();}
else if (held & WPAD_BUTTON_B)
{game_version();}
else if (held & WPAD_BUTTON_1)
{intro();}
If I used && then only the first part of the statement is read (just
held) and not the second. I noticed this because I would hit A and it would bring up the exit_menu() (since it's the first conditional statement), but once I removed a & the code ran the way I intended. This isn't a major problem, but I also want to know if I need to use I instead of II.
Thanks,
~BW
I learned this from:
[
cplusplus.com]
at logical operators.