Marco

Marco

  • NA
  • 59
  • 0

passing by value

Nov 1 2007 12:09 PM
Hello, I have this problem:

void append (Node n) { //here construct the my list }
void remove(Node n) { find and remove n from the list and change the pointers as well }
void myMethod (LinkedList list, Node n) {
    list.remove(n);
}

static main () {
  List <Node> linkedlist = new List <Node> ll;
  for (int i=0; i< 10; i++) ll.append(new Node (i));
  myMethod (ll, new Node (4));
  //here I'd like that linkedList wasn't changed !!!! (but it's changed)
}

Can I do value passage in this case? thanks


Answers (4)