Hello. I am working on a data structures program that should be quite easy, but after programming in assembly language using mips, I forgot a little bit of C++ and can't remember how to do this. I've used my googlefu for at least 2 hours and still have this problem.
The error:
head undeclared, first use this function.
The code it is talking about
void node::insertNode(int id, string name, double average,int *array)
{
node *newNode; //a new node
node *nodePtr; // to traverse the list
node *previousNode = NULL; //the previous node
cout << "test 2";
//allocate a new node and store the values there
newNode = new node;
newNode->data.setStudentAverage(average);
newNode->data.setStudentName(name);
newNode->data.setStudentId(id);
newNode->data.setStudentTests(array);
cout << "test 3";
//If there are no nodes in the list
//make newNode the first node
if(!head)
{
cout << "test 4";
head = newNode;
newNode->next = NULL;
}
There is more but the program never made it to test 4.
Now it won't even complile.
Here is the node part of the header file.
class node
{
private:
student data;
node *next;
public:
node();
void insertNode(int id, string name, double average, int *array);
void deleteNode(int id);
void displayList();
};
#endif
And here is the constructor within the cpp
node::node()
{
node *head;
}
I don't know exactly where I'm not declaring it seeing as I am pretty sure that is the declaration. please help if you can and I'm sorry if it's completely messy.
Thank you for your help! I am still trying to figure it out on my own.