what is function of |= operator in C++?

like if we write a |= b;

what does |= do here?

thanks.

Printable View

- 02-04-2009sunny_master_07|= operator in C++
what is function of |= operator in C++?

like if we write a |= b;

what does |= do here?

thanks. - 02-04-2009matsp
If we assume that a and b are integer, then a |= b is the same as a = a | b, which is a bitwise or - so all bits that are set in b gets set in a as well.

--

Mats - 02-04-2009laserlight
Read the tutorial on bitwise operators. a |= b is short hand for a = a | b.