In the following program how bitwise AND work for class variable? As we know: if(7 && 8) evalutes TRUE whereas if(7 & 8) evalutes FALSE. What are the bit values of "f" and "ios::showpos" and how IF verify these two variables?
#include <iostream>
using namespace std;
int main()
{
ios::fmtflags f = cout.flags();
if(f & ios::showpos)
cout <<"showpos is set for cout. \n";
else
cout <<"showpos is cleared for cout \n";
cout <<"\nSetting showpos for cout. \n";
cout.setf(ios::showpos);
f = cout.flags();
if(f & ios::showpos)
cout <<"showpos is set for cout. \n";
else
cout <<"showpos is cleared for cout. \n";
return 0;
}
OUTPUT IS:
showpos is cleared for cout.
Setting showpos for cout.
showpos is set for cout.