Author Topic: Abstract class constructors  (Read 3098 times)

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Abstract class constructors
« on: March 17, 2004, 02:31:08 pm »
Herewith, my entry for "Dumbest question of the Week" 8)

Can an abstract class have a constructor?  What I mean is, even though (to us) an abstract class constructor seems to be a meaningless concept, are there any circumstances where it would not be meaningless.

???
Bruce
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

jkorman

  • EA User
  • **
  • Posts: 99
  • Karma: +0/-0
    • View Profile
Re: Abstract class constructors
« Reply #1 on: March 17, 2004, 07:20:44 pm »
Sure. Consider

public abstract class Foo {

 Foo() { init(); }

  public abstract init();
}

The method init() is declared and used in the abstract base class, but is defined
in some concrete inheriting class.

Jim

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Abstract class constructors
« Reply #2 on: March 17, 2004, 08:46:45 pm »
Considering ....


PHP?
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.