在《Unix环境高级编程》的7.6节中提到C程序的内存空间可以分为正文段、初始化数据段、非初始化数据段、栈、堆。其中初始化数据段包含程序中需明确赋初值的变量,如C语言中的全局变量int maxcount = 99;。非初始化数据段又称为bss(block started by symbol)段,在程序开始之前,内核将此段初始化为0或空指针,如出现在函数外面的long sum[1000];,该变量没有明确赋初值,因此放到了bss段中。 而在C++语言中,将所有的全局对象当做初始化过的数据来对待,因此不会将全局变量放到bss段中。
POD数据类型
书中提到Plain ol’ data,查了下应该叫Plain Old Data,简称POD,指C风格的struct结构体定义的数据结构,其中struct结构体中只能定义常规数据类型,不可以含有自定义数据类型。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
typedef struct Point { float x, y, z; } Point;
Point global;
Point foobar() { Point local; Point *heap = new Point(); *heap = local; delete heap; return local; }
下面内容为快捷键列表: :A switches to the header file corresponding to the current file being edited (or vise versa) :AS splits and switches :AV vertical splits and switches :AT new tab and switches :AN cycles through matches :IH switches to file under cursor :IHS splits and switches :IHV vertical splits and switches :IHT new tab and switches :IHN cycles through matches ih switches to file under cursor is switches to the alternate file of file under cursor (e.g. on <foo.h> switches to foo.cpp) ihn cycles through matches