Hey guys. I have a few years of programming under by belt but I'm new to C++ (coming from mostly Java and C#). I have a linked list that seems to work properly except for the add method. The nodes of the linked list are AdjacencyListNode objects that just have an int (variable name is data) and a pointer (variable name is next) to the next node.

Adding the first node to the list behaves properly. Adding the second node does add a second node, but the data in the node is that of the first. In general there is just some weird behavior going on. I've posted the add method and the part of the program that calls this. The output is below the code. If anyone sees something that is incorrect, please tell me. Thanks for your time guys

Code:
//============================================
// Adds a new node to the beginning of
// the list. Parameter node is the pointer to
// the node that will be added to the list.
//
// PRE:  AdjacencyList with size n is defined
// POST: AdjacencyList with node added to the 
//       front of the list. Length is n + 1.
//============================================
void AdjacencyList::add(AdjacencyListNode * node)
{
	// Check if list is empty
	if (first == NULL)
		first = node;

	else //List not empty 
	{
		//Hook up new node's next
		node->next = first;

		// Set first to new node
		first = node;
         }
		//Increment length
		length++;
}
Here's the part of the main program that calls this:
Code:
	AdjacencyList list;
	list.add(new AdjacencyListNode(2));
	list.display();

	list.add(new AdjacencyListNode(3));
	list.display();

	list.add(new AdjacencyListNode(4));

	list.display();

	cout << list.length << endl;
And finally the output:
Code:
Displaying List:
Node Data: 2
Displaying List:
Node Data: 3
Node Data: 3
Displaying List:
Node Data: 4
Node Data: 4
Node Data: 3
3