摘要: 很多C++书籍中都介绍过,一个Class对象需要占用多大的内存空间。最权威的结论是:*非静态成员变量总合。(not static)*加上编译器为了CPU计算,作出的数据对齐处理。(c语言中面试中经常会碰到内存对齐的问题)*加上为了支持虚函数(virtual function),产生的额外负担。下面给出几个程序来看一下:#include <iostream>#include <cstdio>#include <string>using namespace std;class Car1{};void fun1(void){ int size =0; Car1 o 阅读全文
posted @ 2012-10-24 18:13 xiulug 阅读(2542) 评论(0) 推荐(1) 编辑