Thread: clone problem
View Single Post
  #14 (permalink)  
Old 01-13-2008, 12:55 PM
tim's Avatar
tim tim is offline
Senior Member
 
Join Date: Dec 2007
Location: South Africa
Posts: 334
tim is on a distinguished road
Had the same problem
Hello feniger

I had the same problem:
Quote:
Originally Posted by feniger
the source of my problem was my lack of knowledge in cloning,
what I found out is that I have to clone EVERY type of Object withing the class/object I am cloning, which means if I have an object, that one of its fields (attributes) is not a primitive data type, but another object (for example: Square will have int row, int col, but also a PieceType pieceOnSquare)
then I'll have to clone pieceOnSquare as well,
That's why I said:
Quote:
Originally Posted by tim
The problem could be in any of the clone() methods that you defined
Cloning objects is useful though. Do not be afraid to implement cloning because it is strange.
__________________
If your ship has not come in yet then build a lighthouse.
Reply With Quote