c++ primer plus 第6版 部分三 9章 - 章 第9章 内存模型和名称空间 1.单独编译 组件函数放在独立的文件中.可以单独的编译这些文件,然后链接成可执行的程序. 三部分 a 头文件: 包含结构声明和使用这些结构的函数的原型 b 源代码文件:包含与结构有关的函数的代码 c 源代码文件:调用结构的函数的代码 除非函数为内联函数,否则不要在头文件中包含函数的定义 头文件中通常包含的内容:…
练习3.1 #include <iostream> using namespace std; int main() { int sum = 0, val = 50; while (val <= 100) { sum += val; ++val; } cout << "Sum of 50 to 100 inclusive is " << sum << std::endl; return 0; } #include <iostre…
看完C prime plus(第五版)第十二章,随带完成了后面的习题. 1.不使用全局变量,重写程序清单12.4的程序. 先贴出12.4的程序,方便对照: /* global.c --- 使用外部变量 */ #include <stdio.h> ; //一个外部变量 void critic(void); int main(void) { extern int units; printf ("How many pounds to a firkin of butter?\n")…