   using a private pointer of a clas with the new operator
  I'm creating a linked list, and the pointer to the next object is in the private section of the class.  I have a function that returns the this pointer, but when I try to use the this pointer returned by the function with the operator new I get an error.  The error is that I need an Lvalue.  Since I am not dereferencing the this pointer before returning it, I am a bit confused.  Here is the appropriate info to help me.#ifndef Node_h#define Node_henum type{endpoint = 0 , jump = 1};class Node{public:Node( int x = 0, int y = 0, int id = 0 , Node *next = 0 , type style = endpoint);~Node();int Return_Id(); int Return_X() { return x_; }int Return_Y() { return y_; }Node * Return_NodePointer() { return next_; }private:int x_ , y_ , id_;type type_;Node *next_;};#endifvoid CreateNodes(Node ** head){...unimportant code here  else  {   for( ; (*head)->Return_NodePointer() ; *head = (*head)->Return_NodePointer() );(*head)->Return_NodePointer() = new Node(x, y, num_nodes, 0);//error C2106: '=' : left operand must be l-value...unimportant code here}[edited by - native_light on August 3, 2003 11:10:27 PM]
  Alright its been a long time since i did c++, so i cant give u an exact solution.But what u r doing here:(*head)->Return_NodePointer() = new Node(x, y, num_nodes, 0);//is like:8 = new Varyou cant have (*head)->Return_NodePointer() on the left side of the equal sign because it is not a variable, it is truly the data of the object you called, and not what you are expecting here.[\Edit]Actually... as i said i have forgotten a lot of this, but are you passing those pointers by reference???? If they are not the i think they should b if im reading ur code correctly. [edited by - ju2wheels on August 3, 2003 12:05:23 AM];quote:Original post by native_light  (*head)->Return_NodePointer() = new Node(x, y, num_nodes, 0);//error C2106: ''='' : left operand must be l-valueThe problem is that Return_NodePointer returns a pointer value. You are trying to compile something similar to this: 0 = new Node( ... );    which doesn''t compile of course.This code will compile: *((*head)->Return_NodePointer()) = new Node(x, y, num_nodes, 0);    but that''s not what you want to do.What you need to do is implement something like this: Node * Node::Link( Node * p ){    Node * old_next = next_;    next_ = p;    assert( p->next_ == NULL );    p->next_ = old_next;    return p;}    and then change your CreateNodes function to this: void CreateNodes(Node ** head){...unimportant code hereelse{for( ; (*head)->Return_NodePointer() ; *head = (*head)->Return_NodePointer() );(*head)->Link( new Node(x, y, num_nodes, 0) );...unimportant code here}  ;  (*head)->Return_NodePointer() = new Node(x, y, num_nodes, 0);so many confusing pointers..your function returns a pointer, this allows you to change whats _behind_ the pointer, but you want to change the pointer itself. so either return a reference to the pointer (*&) which should let your remaining code untouched or return a ** and dereference it. your function will return a copy, a temporary object you can consider as const. what you try is more like (a+b)=5;  not the other way round. 