Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Copy Constructor help.

 
Andrew Gary
Greenhorn
Posts: 8
Chrome Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having trouble making a copy constructor for this ListType class, the list type class implements the GeneralList interface, which is down below the ListType class.

I have to create a copy constructor that accepts a reference to another GeneralList Object.

Here is the ListType class


And here is the GeneralList interface

Here is what I have come up with, but it does not work.
Could someone help me understand why this copy constructor does not work, and how to modify it so that it does work?


Thanks for any help, it's much appreciated.
 
Praveen Kumar M K
Ranch Hand
Posts: 256
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,

In the copy constructor, you are not setting the value of the number of elements. Although the "list" array has the right values, elements is still = 0.
 
Andrew Gary
Greenhorn
Posts: 8
Chrome Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh thanks! I never catch my own stupid mistakes ha. Appreciate the help!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic