久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

內(nèi)存布局 C++ 對象

memory layout C++ objects(內(nèi)存布局 C++ 對象)
本文介紹了內(nèi)存布局 C++ 對象的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我基本上想知道 C++ 如何在內(nèi)存中布置對象.所以,我聽說動態(tài)轉(zhuǎn)換只是用偏移量調(diào)整內(nèi)存中對象的指針;和 reinterpret 類型允許我們用這個指針做任何事情.我真的不明白這一點.細(xì)節(jié)將不勝感激!

I am basically wondering how C++ lays out the object in memory. So, I hear that dynamic casts simply adjust the object's pointer in memory with an offset; and reinterpret kind of allows us to do anything with this pointer. I don't really understand this. Details would be appreciated!

推薦答案

每個類都按照聲明的順序排列其數(shù)據(jù)成員.
允許編譯器在成員之間放置填充以提高訪問效率(但不允許重新排序).

Each class lays out its data members in the order of declaration.
The compiler is allowed to place padding between members to make access efficient (but it is not allowed to re-order).

dynamic_cast<> 的工作原理是編譯器實現(xiàn)細(xì)節(jié),標(biāo)準(zhǔn)中沒有定義.這完全取決于編譯器使用的 ABI.

How dynamic_cast<> works is a compiler implementation detail and not defined by the standard. It will all depend on the ABI used by the compiler.

reinterpret_cast<> 只需更改對象的類型即可.您唯一可以保證有效的是,將指向 void* 的指針轉(zhuǎn)換為指向 class 的指針將返回相同的指針.

reinterpret_cast<> works by just changing the type of the object. The only thing that you can guarantee that works is that casting a pointer to a void* and back to the same the pointer to class will give you the same pointer.

這篇關(guān)于內(nèi)存布局 C++ 對象的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

What do compilers do with compile-time branching?(編譯器如何處理編譯時分支?)
Can I use if (pointer) instead of if (pointer != NULL)?(我可以使用 if (pointer) 而不是 if (pointer != NULL) 嗎?)
Checking for NULL pointer in C/C++(在 C/C++ 中檢查空指針)
Math-like chaining of the comparison operator - as in, quot;if ( (5lt;jlt;=1) )quot;(比較運算符的數(shù)學(xué)式鏈接-如“if((5<j<=1)))
Difference between quot;if constexpr()quot; Vs quot;if()quot;(“if constexpr()之間的區(qū)別與“if())
C++, variable declaration in #39;if#39; expression(C++,if 表達式中的變量聲明)
主站蜘蛛池模板: 欧美一区二区在线免费观看 | 日日摸日日爽 | 日韩欧美一区二区三区在线播放 | 国产a级毛毛片 | 国产亚洲精品精品国产亚洲综合 | 国产精品视频一区二区三区不卡 | 久久毛片 | 婷婷91| 欧美女优在线观看 | 一区在线播放 | 国产日韩欧美一区二区 | 国产福利在线视频 | 国产精品1区| 日韩精品一区中文字幕 | 久久精品成人 | 国产在线精品区 | 久久久久亚洲精品国产 | 狠狠热视频 | 久久久精彩视频 | 在线激情视频 | 欧美日韩看片 | h视频在线免费观看 | 欧洲色综合 | 国产精品资源在线 | 日本精品视频 | 这里只有精品999 | 亚洲精品视频在线看 | 久久精品综合 | 欧美极品在线观看 | 亚洲在线一区二区 | 9久久精品 | 狠狠操狠狠操 | 久久精品久久综合 | 91人人视频在线观看 | 亚洲成人在线免费 | 日韩在线小视频 | 亚洲高清av | 国产一二三区免费视频 | 亚洲午夜精品 | 亚洲入口 | 免费a在线|