1 Chapter - Preparing Knowledge
- Generic Programming(泛型编程)
- Object Oriented Programming(面对对象编程)
data + method = program
C | C++ |
---|---|
procedural language | object oriented language |
stress algorithm | stress data |
top-down | bottom-top |
2 Chapter - Start to Learn C++
2.1 main()
int main()
{
statements;
return 0;
}
2.2 C++ Preprocesser and Iostream Headfile
#include <iostream>//将iostream文件的内容添加到程序中,然后再和源码一起编译
using namespace std;//简化程序,保证可以使用输入输出工具
2.3 Namespace
If you use iostream instead of iostream.h, you need add using compliling command to make iostream definition avalible
using namespace std;//using 编译指令,使得std名称空间中的所有名称都可用
// 用到哪个名称就使哪个名称可用
using std::cout;
using std::endl;
using std::cin;
2.4 Use cout to Output
cout | trait | function |
---|---|---|
predefine object(预定义对象) | << | insert right information to ostream |
endl | trait | function |
---|---|---|
manipulater(控制符) | none | start a new line |
cin | trait | function |
---|---|---|
predefine object(预定义对象) | >> | take proper value from istream to right variable |
2.5 Class Introduction
Class decribe one data type’s all properties(including its operating method)
Object is a real thing launched by class description
Use special object to execute special operation(send message to object)
- Use class method
- Operator overloading ( cin and cout )
Summary
C++ has six types case:
- declaration case(声明语句)
- evaluation case(赋值语句)
- message case(消息语句)
- function invoking case(函数调用)
- function prototype case(函数原型)
- return case(返回语句)