I have a pretty specific data structure issue that I cannot figure out. For my assignment, I must have a dynamically allocated array of structures in my private section of my header. So, up to this point, in my header file, I have
struct node{
int name;
node *next;};
In my private, I have
node *adj;
which is, at least to my knowledge, how you would set up having the array.
Then, in my .cpp file, I have
adj = new node*[];
This is throwing a bunch of errors. But, when I have
node *adj[n];
in my cpp and nothing in my header, it works. My questions is how do I have an array in my private section of my header, but dynamically allocate the space in my .cpp?
node *adj;is not an array of pointers, it is a pointer tonode.node **adgwould be an array of pointers.adj = new node*[];