Hey everyone...
So, I just spent the past hour tooling around with this code...the concept of Linked lists isnt clicking in my head for some reason (I'm sure it has NOTHING to do with the size of my brain.... ) ANYWAYS! So using the tutorial from this website along with a couple of books of mine, I've been trying to piece together a program that creates a SIMPLE linked list...but I'm not exactly sure what I'm doing...the following code doesnt compile with an error of "left operand must be l-value" in reference to the commented line:
Code:
#include <iostream>
using namespace std;

class node
{
public:
   node(int age = 0):m_age(age), m_pNext(0) {}
   int GetAge() const {return m_age;}
   node* GetNext() const {return m_pNext;}
   void SetNext(node* next) {m_pNext = next;}
private"
   int m_age;
   node* m_pNext;
};

int main()
{
   node* pHead = new node(5);
   node* pConductor = pHead;
   if (pConductor != 0)
   {
        while (pConductor->GetNext() != 0)
               pConductor = pConductor->GetNext();
   }
   pConductor->GetNext() = new node(9); //this is the error
   return 0;  //program ends abruptly...I know
}
Basically what I'm trying to do is create multiple nodes...how do I go about doing this...the tutorial definitely pushed me a GIANT step forward (I cant emphasize how much it helped me progress) but I seem to be missing something...any insight would be very much appreciated...thanks! -Chap