标签:
1.普通类型:(创建后的指针需要用完对其释放)
int a=10; int *aP=&a; cout << *aP << endl;
int *aP=new int; *aP=8; cout << *aP << endl; delete aP;
2.数组:(单类型释放需要执行 delete type,对于数据的释放 需要执行delete[] )
int arraySize=8; int *myArr2=new int[arraySize]; myArr2[0]=3; cout << myArr2[0] << endl; delete [] myArr2;
3.结构体:
typedef struct{ char firstInitial; char middleInitial; char lasyInitial; int employeeNum; int salery; } EmployeeT;
EmployeeT *employeeP=new EmployeeT; employeeP->salery=200; cout << (*employeeP).salery << endl;
4.字符串创建的3种形式:
char str1[20]="hello world !"; char *str2="hello world !"; string str3="hello world !";
标签:
原文地址:http://blog.csdn.net/qq285016127/article/details/45243327