Linked list of objects
I am trying to create a linked list of the following style:
Basically, a pointer to an object and a pointer to the next node of the list. Is this the correct way of doing it?
#include "variable.h" // CLASS called variable
struct node *next;
typedef struct node nodeptr;
I'm not sure how to set and access the object either. So far I have been trying this but it has not worked
ptr->objectPtr = new variable(VarID,constant);
Thanks for help
cout << (ptr->objectPtr).GetVarID() << endl; //GetVarID() is a member function
Since objectPtr is a pointer, why are you not using -> to access it's content (including it's member functions).
I can confirm that this now works
cout << ptr->objectPtr->GetVarID() << endl;