1.A variable pointer to a constant value 变量指针指向一个常量数据
Shortly:Pointer to Constant(常量指针/常指针) 特征:指针指向的内容不可以通过指针的间接引用(*p)来改变
const int* p1;
const int x = 1; //x 是常量
p1 = &x; //指针 p1的类型是 (const int*)
*p1 = 10; //10赋给一个常量,所以是错的。
2.An invaraible pointer to a variable value
Pointer Constant ( 指针常量 )
- 指针本身的内容是一个常量,不可以改变
- 数组名就是数组首地址的别名,现在可以说:数组名就是一个数组常量。
int x = 1,y = 1;
int* const p2 = &x;//常量p2的类型是(int*),p2是常量,指向的是变量。
*p2 = 10; //Okay! -> x = 10;
p2 = &y; //Error! p2 is a constant
3.指针常量(int * const y):首先是一个常量,然后是指针类型(地址)的常量
常量指针(const int * x):首先是一个指针,然后是指向常量的指针
point:【在前先读、在前不变】
* (指针) 和 const(常量)谁在前先读谁;
* 代表被指的数据,名字代表指针地址
const在谁前面谁就不允许改变
4.面向对象的特征(A pie)
Abstraction (抽象)
Polymorphism (多态)
Inheritance (继承)
Encapsulation (封装)
5.对象:【同类型的对象用一个通用的类来定义】
唯一标识
状态(数据域 以及 当前值)
行为(一组函数定义)
6.类的抽象与封装
【Class abstraction(类抽象)】
- to separate class implementation from the use of the class(将类的实现与使用分离开)
- The creator provides a class desecription(类的创建者提供类的描述)
- The user of the class does not need to know how the class is implemented(使用者不需要知道类是如何实现的)
【Class encapsulation(类封装)】
- The detail of implementation is encapsulated and hidden from the user(类实现的细节被封装起来,并对用户是隐藏的)