Re: [問題] realloc在cpp中有替代方案嗎?

看板C_and_CPP (C/C++)作者 (躂躂..)時間18年前 (2006/06/14 17:31), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
推 cplusplus:原因我是忘了 找看看C++ Object Model吧 裡面有提到 您好, 在您提的書我剛找來翻了 :) 因為書中提到的部份是根據spec來的, 所以我摘spec中對於data member順序配置的部份出來. 大意是說, 同一access下有要求先宣告先配置, 但不同access下的順序沒有明定. C++98與C++03的定義一樣, 內文如下: 9.2 Class members 12. Nonstatic data members of a (non-union) class declared without an intervening access-specifier are allocated so that later members have higher addresses withing 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 classese (10.1). 然後作者提到, 雖然不同access下的順序沒有定義, 但整個class仍是要 配成連序空間. 原文在 Inside The C++ Object Model (3.2 Data member layout) 感謝cplusplus提供書藉資訊 :p -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.138.150.96

06/14 20:46, , 1F
當然不管怎樣都會連續配置 只是不能亂搞記憶體 :)
06/14 20:46, 1F
文章代碼(AID): #14ZzU5h6 (C_and_CPP)
文章代碼(AID): #14ZzU5h6 (C_and_CPP)