This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Micro Frontends in Action and have Michael Geers on-line!
See this thread for details.
Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Copy Constructor help.

 
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.
 
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!!
 
eat bricks! HA! And here's another one! And a tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic