Explain C++ function
by stockton from LinuxQuestions.org on (#4Y012)
Please explain the following piece of C++ to me
void cSkymax::SetMode(char newmode)
{
m.lock();
if (mode && newmode != mode)
ups_status_changed = true;
mode = newmode;
// printf("%s %d %s %s\n", __FILE__, __LINE__, mode, newmode);
m.unlock();
}
both mode and newmode are defined as char but I am failing to see how mode && newmode can be compared to a char. Surely && returns TRUE or FALSE not a char.
I am also assuming that m.lock and m.unlock are stopping memory swopping.
The reason for my question is that I require to do this function in C not C++ and I know very little about C++


void cSkymax::SetMode(char newmode)
{
m.lock();
if (mode && newmode != mode)
ups_status_changed = true;
mode = newmode;
// printf("%s %d %s %s\n", __FILE__, __LINE__, mode, newmode);
m.unlock();
}
both mode and newmode are defined as char but I am failing to see how mode && newmode can be compared to a char. Surely && returns TRUE or FALSE not a char.
I am also assuming that m.lock and m.unlock are stopping memory swopping.
The reason for my question is that I require to do this function in C not C++ and I know very little about C++