• 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

superclass' default construct

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, all:

The default constructor(no arguments) in Class B is needed to compile the constructor marked **. why?
thanks.
Added code tags - Barry
[ August 18, 2003: Message edited by: Barry Gaunt ]
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any subclass Constructor that does not have an explicate call to it's Super class Constructor gets an implicate call to the super classes default constructor. The code:

is exactly the same as
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is class A extending Demo or B?
If it's B, then, as Carl has said, there is an implicit call to B's no argument constructor as the first statement in the A(int, int) constructor.
[ August 18, 2003: Message edited by: Barry Gaunt ]
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shoot, thanks Barry, I quick scanned the question and missed the fact that A extended Demo and not B. I assumed it did just by the nature of the question.
 
reply
    Bookmark Topic Watch Topic
  • New Topic