如何创建指针数组? [英] How do I create an array of pointers?
本文介绍了如何创建指针数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建一个指针数组.这些指针将指向我创建的 Student 对象.我该怎么做?我现在拥有的是:
I am trying to create an array of pointers. These pointers will point to a Student object that I created. How do I do it? What I have now is:
Student * db = new Student[5];
但该数组中的每个元素都是学生对象,而不是指向学生对象的指针.谢谢.
But each element in that array is the student object, not a pointer to the student object. Thanks.
推荐答案
Student** db = new Student*[5];
// To allocate it statically:
Student* db[5];
这篇关于如何创建指针数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文