Do these members have unspecified ordering?

A colleague told me that, in the following type, all members have unspecified ordering in memory (relative to one another).

I doubt this, because they all have the same access level.

Who is correct?

struct foo { public: int x; public: int y; public: int z; };

Solution 1:

Your colleague is correct for C++03:

[C++03: 9.2/12]: Nonstatic data members of a (non-union) class declared without an intervening access-specifier are allocated so that later members have higher addresses within a class object. The order of allocation of nonstatic data members separated by an access-specifier is unspecified (11.1). [..]

But you are correct for C++11:

[C++11: 9.2/14]: Nonstatic data members of a (non-union) class with the same access control (Clause 11) are allocated so that later members have higher addresses within a class object. The order of allocation of non-static data members with different access control is unspecified (11). [..]

(Spot the difference.)