Click to See Complete Forum and Search --> : Dumb C++ Question


Plasmator
August 4th, 2006, 02:52 PM
Hey, sorry for the silly question, but is:

int a = 1, b = a;

defined behavior? that is, if a is initialized properly, b is guaranteed to equal a provided that a is initialized before b, but not as a separate statement delimited by a ';', but delimited by a comma like the example above?

I just want to make sure that I'm not walking in undefined-behavior territory here...

Thx.

JohnyDog
August 4th, 2006, 03:31 PM
Yes, comma is sequence point just like semicolon, so it's ok.

Plasmator
August 4th, 2006, 03:51 PM
Thx!

Calculator
August 4th, 2006, 10:46 PM
http://msdn2.microsoft.com/en-us/library/zs06xbxh.aspx

Left to right evaluation.

Plasmator
August 4th, 2006, 10:57 PM
Thx for the reference. I seriously thought that MSDN mainly covered WinAPI stuff, heh, thx again.