Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

superclass' default construct

 
Roger Zhao
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • 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 ]
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • 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
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic