此篇文章来源于斯坦福的计算机编程课,
网址:http://web.stanford.edu/class/cs106b/
每次重头开始看书都是看那些基本语法,语法看得太多并没有任何效果,以后不再复习C的基础知识,比如变量,语句,循环看得再多也还是不会面向对象,以后要看深入的的知识。
简单摘抄几个句子。
00. 目录
1. Overview of C++
1.1 Your first C++ program
1.2 The history of C++
1.3 The structure of a C++ program
1.4 Variables
01. C++常见的的命名规则,属性和方法小写开头,类使用大写,单词之间首字母大写。常量全部大写,可以用短划线隔开各个。
In this text, names of variables and functions begin with a lowercase letter, such as limit or raiseToPower. The names of classes and other programmer-defined data types begin with an uppercase letter, as Direction or TokenScanner.
Constant values are written entirely in uppercase, as in PI or HALFJOLLAR. Whenever an identifier consists of serveral English words run together, the usual convention is to capitalize the first letter of each word to make the name easier to read.
Because that strategy doesn't work for constants, programmers use the underscore character to mark the word boundaries.
1.5 Data types
02. 类型
In C++, every data type value has an associated data type. From a formal perspective, a data type is define by two properties: a domain, which is the set of values that belong to that type, and a set of operations, which defines the behavior of that type.
03. 枚举
The syntax for defining an enumerated type is
enum typename {namelist};
Where typename is the name of the new types and namelist is a list of the constants in the domain, separated by commas.
04. 优先级
If two operators have the same precedence, they are applied in the order spcified by their associativity, which indicates whether that operator group to the left or to the right.
1.6 Expressions
1.7 Statements
Summary
Review question
05. 习题
review
1. source file
2. // /* */
3. <>表示系统标准库 " "自己写的头文件
4. const duoble CENTIMETERS_PER_INCH = 2.54;
5. main return 0;
6. 屏幕上换行
7. 名字 类型 数值 范围
8. c f
9. member operator
10. 表示的范围不同
11. 美国字符
12. true false
13. double x; cin >> x;
14. cout << "i = " << i << ", d = " << d << ", c = " << c << ", s = " << s << endl;
15. int 5, int 3, double 4.8, double 18, int 4, int 2
16. unary表示负值,substraction表示减法操作。
17. 去掉小数部分
18. 一种类型转化为另一种类型, type (var)
19. 4
20. var1 += var2
21. ++x 先将x加1再进行操作。
22. short-circuit evaluation 在&&