6 ms·
No, the same restrictions apply to class as to struct. The most relevant difference in C++ is that the compiler can reorder data members that are in different v
by archangel_one 13y ago
No, the same restrictions apply to class as to struct.
The most relevant difference in C++ is that the compiler can reorder data members that are in different visibility specifications (public, protected, private) but not within one of those blocks, to maintain compatibility with C.
- pandaman 13y agoThis is what I said. Even though they could change the rules for the classes they did not because it's far from "free".
- haberman 13y agoWell you only have guaranteed compatibility with C if a class is standard-layout, which requires that all members have the same access control (public, protected, private). So if there is any rule in C++ that mandates ordering within a "block" when there are multiple such "blocks", it's not for compatibility with C.
- pmr_ 13y agoFunnily, this is one of the freedoms granted by the standard which neither gcc, clang, or MSVC actually make use of.