How can i code in c++ an 'AND' gate using c++.Help me-urgent please..
Printable View
How can i code in c++ an 'AND' gate using c++.Help me-urgent please..
&& <--- logical AND
& <--- bitwise AND
or did you want to overload & and provide your own?
Well, if you're doing some sort of binary logic, then you've got signals that are zeros and ones, much like boolean variables.
bool a, b, result;
// ... get a and b from somewhere
result = a && b; // perform logical and of a and b and place in result
You could save a lot of memory space if you only used one bit for each and stuffed like 8 results into a byte, using the bitwise and, but it looks like you're better off starting here.