struct array

How can i access in a struct array the higher elements of the array.

Here the code:

#include <iostream>

using namespace std;

struct tree
{
int a;
tree *next;
};

int main()
{
int g;
cin>>g;
tree *start = new tree [g]
for(int i=0; i<g; i++)
{
//Here i want to access each element of the array
}
}

I`ve tried cursor[i]->a and cursor->a[i]. The second seems for me right, only if a is an array in struct like:
struct table
{
int a[];
table *next;
};

The first seemes to be better but on compiling i get following error message:
base operand of `->`has non-pointer type 'tree'
"cursor" did you mean "start" ?
start is a tree*, start[i] is a tree so you can't use -> with it. You need .
start[i].a
Thx
sorry i`ve simplified the code and accidentally made a mistake.
Thank you for helping.
topic can be closed
Topic archived. No new replies allowed.