Now I’m assuming you wrote the code exactly as specified:
struct node *nodes[1024];
nodes[1]->data = 1;
nodes[1]->left = NULL;
nodes[1]->right = NULL;
The reason you are getting compiler errors is because that is not valid C++ code.
But if you move that code into a function it will compile just fine:
struct node *nodes[1024];
void AddFunction()
{
nodes[1]->data = 1;
nodes[1]->left = NULL;
nodes[1]->right = NULL;
}