锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
1. sizeof 綾?br />sizeof 綾誨拰緇撴瀯鍏跺疄宸笉澶氾紝閮借娉ㄦ剰瀵歸綈鐨勯棶棰樸傚茍涓旓紝sizeof 絀虹被 = 1銆?br />sizeof 綾昏娉ㄦ剰鐨勬槸錛?br />1) 娌℃湁铏氬嚱鏁幫細(xì)sizeof(鏁版嵁鎴愬憳)鐨勫拰
2)聽鏈夎櫄鍑芥暟錛歴izeof(鏁版嵁鎴愬憳)鐨勫拰+sizeof(V琛ㄦ寚閽?=4
渚嬪錛?/p>
class
聽A
{
聽聽聽聽
double
聽a;
}
;

class
聽A1:聽
public
聽A聽
{
聽聽聽聽
int
聽pop();
}
;

class
聽A2:聽
public
聽A聽
{
聽聽聽聽
virtual
聽
int
聽pop();
}
;
int
聽main(
void
)
{
聽聽聽聽cout聽
<<
聽
sizeof
(A)聽
<<
聽endl聽
<<
聽
sizeof
聽A1聽
<<
聽endl聽
<<
聽
sizeof
聽A2聽
<<
聽endl;
聽聽聽聽
return
聽
0
;
}
緇撴灉鏄?8 8 16
璇存槑錛氫箣鎵浠izeof A2鏄?6錛屾槸鍥犱負(fù)瀵歸綈鐨勯棶棰橈紱濡傛灉綾籄鐨勬暟鎹垚鍛樻槸int a錛屽垯緇撴灉鏄?銆?img src ="http://m.shnenglu.com/wform/aggbug/15146.html" width = "1" height = "1" />
]]>