Initialing a boolean variable thru comparison operator

There are time when we try to compare and the point is only to initialize a boolean variable. Sample,

if(var1 == var2)
{
  bVar = true;
}
else
{
  bVal = false;
}

So, instead of the long code above you can shorten it to:

bVar = (var1 == var2);

That's it!

Comments

Popular posts from this blog

Creating tray application and popup context menu in Windows

How to implement mouse drag using wxWidgets

How to put an image to wxPanel using wxWidgets