Write the definition of a function named alternator that receives no parameters and returns true the first time it is invoked, returns false the next time it is invoked, then true , false and so on, alternating between true /false on successive invocations.

Respuesta :

Visual C++ Programming is the software where the function defined in the question can be used. The return type of the Boolean method is applied. This is the code for the function.

bool newbie()
{
      static bool x = true;
      if (x) {
           return true;
      } else {
           return false;
      }
}
ACCESS MORE