摘要:
记住sizeof是一个运算符,而不是一个函数。在Windows中,下面的结果都是显示为24个字节,这样可以表明在一个struct中,最终的字节数要是在结构体中的占最大字节数的整数倍,这也是内存对齐的要求。看下面这个例子:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--1#includeiostream2usingnamespacestd;34structstr{5charc;6inti;7floatf;8doubled;9};1011str 阅读全文