Well, a simple flag/bool is no different than performing any other check.
Now, the thing is that using flags/bools, often will increase the number of lines of code.
Here's an example where the flag/bool makes the program longer:
int main()
{
bool myflag = false;
int iSomeVal = 10;
if (iSomeVal == 10)
myflag = true;
if (myflag)
cout << "iSomeVal = 10" << endl;
else
cout << "iSomeVal != 10" << endl;
return 0;
}
Here's the same thing done without using a flag/bool:
int main()
{
int iSomeVal = 10;
if (iSomeVal == 10)
cout << "iSomeVal = 10" << endl;
else
cout << "iSomeVal != 10" << endl;
return 0;
}
From the sounds of it, you need to simplify some things. So, if you're code is repeating the same mini-process more than one time that takes several lines of code or more, you can make it simpler by moving those lines into a function/method of their own.
An example of that would be like this:
int main()
{
int iSomeVal = 10;
if (iSomeVal == 10)
cout << "iSomeVal = 10" << endl;
else
cout << "iSomeVal != 10" << endl;
iSomeVal = 50;
if (iSomeVal == 10)
cout << "iSomeVal = 10" << endl;
else
cout << "iSomeVal != 10" << endl;
return 0;
}
You'll notice that the same 4 lines are repeated. For our example, this can be a function call:
void showResult(int val)
{
if (val == 10)
cout << "val = 10" << endl;
else
cout << "val != 10" << endl;
}
int main()
{
int iSomeVal = 10;
showResult(iSomeVal);
iSomeVal = 50;
showResult(iSomeVal);
iSomeVal = 65;
showResult(iSomeVal);
return 0;
}