dynamic memory allocation problem, please help

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
johnbo
Posts: 8
Joined: Wed Jan 11, 2006 12:26 pm

dynamic memory allocation problem, please help

Post 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
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

..Are you building as C or C++ ?
Shoot Pixels Not People!
Makeshift Development
Post Reply