• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Copy Constructor help.

 
Greenhorn
Posts: 8
Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 256
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh thanks! I never catch my own stupid mistakes ha. Appreciate the help!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic