How do I create an array of pointers

0 votes

I'm attempting to build a pointer array. These points will go to a thing I made for students. 

What should I do? What I now have is:

Student * db = new Student[5];

The student object, not a pointer to the student object, is represented by each entry in the array. 

Thanks.

Aug 3, 2022 in C++ by Nicholas
• 7,760 points
1,778 views

1 answer to this question.

0 votes
Student** db = new Student*[5];
// To allocate it statically:
Student* db[5];
answered Aug 5, 2022 by Damon
• 4,960 points

Related Questions In C++

0 votes
0 answers

How to create a dynamic array of integers

How can I use the new keyword ...READ MORE

Jul 15, 2022 in C++ by Nicholas
• 7,760 points
648 views
0 votes
0 answers

How do I declare a 2d array in C++ using new?

How do I declare a two-dimensional array using new? For example, for a "typical" array, I would:      int* ary = new int[Size] but int** ...READ MORE

Jul 15, 2022 in C++ by Nicholas
• 7,760 points
824 views
0 votes
0 answers

How to declare an array of strings in C++?

I am trying to iterate over all ...READ MORE

Jul 26, 2022 in C++ by Nicholas
• 7,760 points
913 views
0 votes
1 answer

How to use std::sort to sort an array in C++

We receive std::begin and std::end in C++0x/11, which are overloaded for arrays: #include <algorithm> int main(){ int v[2000]; ...READ MORE

answered Jun 1, 2022 in C++ by Damon
• 4,960 points
1,786 views
0 votes
0 answers

Simple C++ swap function

Why is it that if I have a method like this to swap two numbers, it doesn't work[swap], (I know I can accomplish this by defining pointers in the prototype and then passing the addresses of the relevant variables in main()), yet it works for arrays without having to supply pointers and addresses? It does not work. void num_exchange(int m, int n); int main(){ int num1 ...READ MORE

Jul 27, 2022 in C++ by Nicholas
• 7,760 points
740 views
0 votes
1 answer

Passing a 2D array to a C++ function

How to pass 2D array to a ...READ MORE

answered Oct 13, 2023 in C++ by Artp

edited Mar 5 33,038 views
0 votes
0 answers

How to make an array with a dynamic size? General usage of dynamic arrays (maybe pointers too)?

I wanna create a program that can ...READ MORE

Aug 5, 2022 in C++ by krishna
• 2,820 points
1,360 views
0 votes
0 answers

How come an array's address is equal to its value in C?

The pointer values and pointer addresses in ...