基本类型:int double float 等均属于基本类型
复合类型:基于其他类型定义的类型,目前只接触了引用和指针;
引用和指针,都实现了对其他对象的间接访问;
引用:引用即别名;
注意: 1、某个对象的引用并非对象,本质只是该对象的别名,因而不能定义引用的引用;
2、函数将引用作为形参时,相当于直接对实参进行操作;由于函数的返回值只有一个,所以通常加上一个引用形参来将我们需要的
量的值传回主函数;
3、变量前加&表示取变量的首地址,只有在定义变量时加&才表示定义引用;
4、the reference is not an object ,so there isnot a pointer to a referrence;but there are referrences to pointers for pointers are objects;
int ival=1024;
int &refVal=ival; //refVal是ival的别名
int &refval; //报错,引用必须被初始化
int *p=&ival; //&表示取地址,不表示引用
int func(&x,&y); //x,y是实参的引用
指针:指向对象地址;
空指针:int *p=nullptr;means p is an empty pointer;and p can be transfered into any other type;
int *p1=nullptr; //等价于=0,meaning p1 is a empty pointer
int *p2=0;
int *p3-NULL; //pre-include cstdlib;is replaced in C++ by nullptr
int *p4,p5; //p4 is a pointer to type int;p5 is a int;the fundamental
<span style="white-space:pre"> </span>//type is "int" not "int *",* is only a strict to p4;