Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "|=" operation mean in C++?

I have the following code and I can't understand what does it mean:

var1 |= var2>0 ? 1 : 2;

Anyone can help me please!

like image 465
Reem Avatar asked Apr 17 '10 08:04

Reem


1 Answers

if (var2 > 0)
  var1 = var1 | 1;
else 
  var1 = var1 | 2;

It's bitwise-or.

like image 101
polygenelubricants Avatar answered Sep 21 '22 13:09

polygenelubricants