The sizeof keyWord gives the amount of storage, in bytes, associated with a variable or a type (including aggregate types). This keyword returns a value of type size_t.
int a = 0; cout<<sizeof(a=3)<<endl; cout<<a<<endl; 輸出為什么是4,0而不是期望中的4,3???就在于sizeof在編譯階段處理的特性。由于sizeof不能被編譯成機器碼,所以sizeof作用范圍內,也就是()里面的內容也不能被編譯,而是被替換成類型。=操作符返回左操作數的類型,所以a=3相當于int,而代碼也被替換為:
int a = 0; cout<<4<<endl; cout<<a<<endl; 所以,sizeof是不可能支持鏈式表達式的,這也是和一元操作符不一樣的地方。