C++中对象指针数组类

来源:互联网 发布:java微信支付开发步骤 编辑:程序博客网 时间:2024/06/15 20:12

这里就不介绍什么是二级指针了,直接看程序领会吧!!

typedef Student * PStudent;

PStudent *stud;//Student **stud;

stud=new PStudent[5];//stud=new Student *[5];每一维都是一个指针

for(int k=0;k<5;k++)

stud[k]=new Student();//为每一维指针new一个类


相对于我来说,这种情况还是第一次见,做了一个分析便把它记录下来了!

一般情况下,我会先想到这种用法代替:

typedef Student *PStudent;

PStudent stud[5];

for(int k=0;k<5;k++)

stud[k]=new Student();


0 0
原创粉丝点击