Page 1 of 1

dynamic memory allocation problem, please help

Posted: Wed Jan 11, 2006 12:35 pm
by johnbo
Hi can anyone help me please, im trying to make a linked list to store info for a pathfinding algorithm, i have some structs to hold info:

// node info structure
typedef struct
{
int f, g, h; // pathfinding evaluation parameters
MapPoint parent; // parent square
int state; // indicates whether square is on open list or not
}AInode;


// data structure to create linked list
typedef struct
{
AInode node;
struct ListNode* nxt;
}ListNode;


and im trying to create a new instance of the ListNode to be the root of the list:

// Create open list
ListNode* openRoot; // create pointer to root node
ListNode* openPtr; // create pointer to move aronud list

openRoot = new AInode; // make pointer point to reserved memery
openRoot->nxt = 0; // end of chain is NULL


but when i compile I get the following error:

error: 'new' undeclared


does anyone know why this does not work? im pulling my hair out. thanks

Posted: Wed Jan 11, 2006 3:20 pm
by Drakonite
..Are you building as C or C++ ?