ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Вторник
26 ноября
57515 Топик полностью
AD (27.04.2006 13:30, просмотров: 1) ответил AD на Может, вот выдержка из документа
На самом деле не может. В _С_ гарантируется порядок In C90, it's 6.5.2.1, verse 11: "Within a structure object, the non-bit-field members and the units in which bit-fields reside have addresses that increase in the order in which they are declared." Но в С++ менять можно, при соблюдении некоторых правил. Например, первый элемент должен оставаться первым и еще несколько, менее значительных. Standard (s.9.2(12)) says: 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). Implementation alignment requirements might cause two adjacent members not to be allocated immediately after each other; so might requirements for space for managing virtual functions (10.3) and virtual base classes (10.1). Однако, Bjarne Stroustrup пишет: we do encourage layout compatibility of PODs with their C equivalents and I don't know of any C++ compiler that doesn't provide that.