Alright so I'm new to C++ and have been programming in java before. I'm trying to get nodes to work but as I understand there is no garbage collection as there was in java. I'm having trouble with the malloc function and here's the code:
1 2 3 4 5 6 7 8 9 10 11
/*
* newNode
* Returns pointer to new Node struct. Initializes next field to NULL, and sets
* data field to input parameter node_data. Private.
*/
NodeRef newNode(int node_data){
NodeRef N = malloc(sizeof(Node));
N->data = node_data;
N->next = NULL;
return(N);
}
And this is the error message: " error C2440: 'initializing' : cannot convert from 'void *' to 'NodeRef'".
What's causing this?