爱猫的狗

拥抱变化

导航

《C++ Primer 4th Edition》读书笔记 - Part I: The Basics

Chapter 2. Variables and Basic Types

[2.1] Beware:float一般只保证6位有效数字,而double至少能保证10位。所以double在保证计算精度方面强于float。

Ex 2.3    34464(warning C4305: “初始化”: 从“int”到“unsigned short”截断。 实际上是100000-65536 )
Ex 2.4    -31072(是100000-65536-65536)
Ex 2.9      Which, if any, of the following are illegal?(c,d,e,f貌似有问题)
      (a) "Who goes with F\145rgus?\012"
      (b) 3.14e1L          (c) "two" L"some"
      (d) 1024f            (e) 3.14UL
      (f) "multiple line
           comment









Ex 2.14 (a) int double = 3.14159; (b) char _; (c) bool catch-22; (d) char 1_or_2 ='1'; (e) float Float = 3.14f;    b、e是有效的




Ex 2.16 (a) int car = 1024, auto = 2048;
(b) int ival = ival; //正确 (c) std::cin >> int input_value; (d) double salary = wage = 9999.99; (e) double calc = calc();

2.3.5 extern int i; // declares but does not define i,这就是extern的作用。
int i; // declares and defines i
可以多次declaration,只能一次definition!


Chapter 3. Library Types
习题428-435未做。


ex5.23 输出10、1。

Part I结束。















posted on 2006-04-13 12:04  anf  阅读(356)  评论(0编辑  收藏  举报