View Single Post
Old Oct 8th, 2007, 5:58 PM   #14
cwl157
Professional Programmer
 
Join Date: Feb 2005
Posts: 344
Rep Power: 4 cwl157 is on a distinguished road
so i could use the clone() method and instead of saying
 // set leftChild
   public void setLeftChild(GridNode newLeftChild)
   {
      leftChild = newLeftChild;
   } // end setLeftChild
i would say something like this (and i havent compile or tried this, i dont have time right now but i just want to get the idea)
 // set leftChild
   public void setLeftChild(GridNode newLeftChild)
   {
      leftChild = (GridNode) newLeftChild.clone();
   } // end setLeftChild
and that will make a seperate exact deep copy, correct? And then whatever i wanted to change in the copy i could and it will only change that one because it is not just a pointer to it, correct?
cwl157 is offline   Reply With Quote