Abstract class hide the implementation and group of similar type data.
Group of data is understandable but implementation hiding is not.
According to the following code:
abstract class area
{
protected $a;
protected $b;
abstract public function CalculateArea($ax, $ay);
}
class rectangle extends area
{
public function CalculateArea($ax, $ay)
{
$this->a = $ax;
$this->b = $ay;
return $this->a * $this->b;
}
}
class ellipse extends area
{
private $c = 3.1416;
public function CalculateArea($ax, $ay)
{
$this->a = $ax;
$this->b = $ay;
return $this->a * $this->b * $this->c;
}
}
$RectangleArea = new rectangle();
echo $RectangleArea->CalculateArea(2, 3);
echo"<br>\n";
$EllipseArea = new ellipse();
echo $EllipseArea->CalculateArea(2, 3);
Here a,b properties in abstract class area that is used to next inherited class rectangle and ellipse. Through this it is understandable that grouping of data satisfied but how the implementation hiding is satisfied? Can anyone clarify it?
Thanks in advance.