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

abstract class

 
Amol Dongre
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why abstract class allow private constructor when abstract class can not be instantiated and private constructor can not be called through super() in subclasses
 
Campbell Ritchie
Sheriff
Posts: 48454
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Amol Dongre
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:


not clear can you explain it briefly
 
Campbell Ritchie
Sheriff
Posts: 48454
56
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can call the private constructor from the public constructor. Another version of the same thingIt is possible to use a private constructor from within the class. In an abstract class, that is probably only useful if called from a non-private constructor. Agreed, it is not something you will want at all frequently.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic