Один участок кода запускается, а другой точно такой же -нет

Почему закомментированный участок кода правильный, а незакомментированный участок кода не запускается?

<?php

class Point
{
    public $x;
    public $y;

    function __construct($x, $y)
    {
        $this->x = $x;
        $this->y = $y;
    }

    function distance(Point $point)
    {
        return sqrt ( pow($this-> x -  $point-> x,2 ) + pow( $this-> y  - $point-> y, 2)   );
    }
}

   $A = new Point (rand(5,20),rand(5,20));
   $B = new Point (rand(5,20),rand(5,20));
   $С = new Point (rand(5,20),rand(5,20));
   $D = new Point (rand(5,20),rand(5,20));


echo "Length AB: ", $A -> distance ($B), "<BR>";
echo "Length BC: ", $B -> distance ($C), "<BR>";
echo "Length DC: ", $C -> distance ($D), "<BR>";
echo "Length DA: ", $D -> distance ($A), "<BR>";


/*
  $A = new Point (rand(5,8),rand(5,8));
  $B = new Point (rand(5,8),rand(5,8));
  $C = new Point (rand(5,8),rand(5,8));
  $D = new Point (rand(5,8),rand(5,8));
  echo "AB: ", $A -> distance ($B),"<BR>" ;
  echo  "BC: ", $B -> distance ($C),"<BR>" ;
  echo "DC: ", $C -> distance ($D) ,"<BR>";
  echo  "DA: ",$D -> distance ($A) ,"<BR>";
*/

?>
vedro-compota's picture

Что значит "не запускается"? Что выводится на экране?

Просьба всегда в виде цитаты показывать, что именно код выводит.

_____________
матфак вгу и остальная классика =)

fgh's picture

Fatal error: Uncaught TypeError: Argument 1 passed to Point::distance() must be an instance of Point, null given, called in W:\domains\localhost\0.php on line 23 and defined in W:\domains\localhost\0.php:12 Stack trace: #0 W:\domains\localhost\0.php(23): Point->distance(NULL) #1 {main} thrown in W:\domains\localhost\0.php on line 12

vedro-compota's picture

$С = new Point (rand(5,20),rand(5,20));

тут судя по всему не английский символ для переменной C используются.

_____________
матфак вгу и остальная классика =)