abstract inheritance

Oh the humanity...

Page 1 of 1

1 Replies - 453 Views - Last Post: 03 July 2009 - 01:10 AM Rate Topic: -----

#1 maffelu  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 36
  • View blog
  • Posts: 185
  • Joined: 21-August 08

abstract inheritance

Posted 03 July 2009 - 12:59 AM

Right.

Some code first to explain my toughts:

<?php

abstract class A{
	abstract public function foo();
}

abstract class B extends A{
	abstract public function foo();
}

class C extends B{
	public function foo(){}
}

?>


This doesn't work and gives the following error:

Fatal error: Can't inherit abstract function A::foo() (previously declared abstract in B) in .....tester.php on line 9

Now, the example above is not exactly what I'm doing, but it's damn close. I have A, which is a very very general root class for basically everything in my class lib. B is a little more specific and acts as base root for a certain part of the class lib, and C is a direct class that inherits B and should implement the foo() function.

Is it not possible to pass on the task of implementing an abstract function?

Is This A Good Question/Topic? 0
  • +

Replies To: abstract inheritance

#2 maffelu  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 36
  • View blog
  • Posts: 185
  • Joined: 21-August 08

Re: abstract inheritance

Posted 03 July 2009 - 01:10 AM

[SOLVED]

Of course, you shouldn't bring it up at all in B:
<?php

abstract class A{
	abstract public function foo();
}

abstract class B extends A{
}

class C extends B{
	public function foo(){}
}

?>

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1