In what ways can a flag be used within the program design?
How can you use multiple flags?
In what ways can a flag be used within the program design?
How can you use multiple flags?
A flag is usually a boolean value that signals logic in your program to do something.
// set the debug flag on
bool debugFlag = true;
// set the verbose flag to false
bool verbose = false;
if (debugFlag)
{
log.currentLine(); // do somthing when in debug mode.
}
if (verbose)
{
// spew more output than nomral.
cout<<"verbose flag is on!";
if (debugFlag)
{
log.currentVerboseLine(); // if we are in verbose more send even more data to the log
}
}
But remember, a semaphore is not a flag!!!!