在正常的数学术语中,-1756046391*-1291488517将等于2267913749295792147.
当我在java中输入完全相同的等式时,我得到答案:-1756046391*-1291488517 = 19.
任何人都可以对此有所了解吗?
当方法在父类中时,如何返回被调用的类的实例.
例如.在下面的示例中,B如果我调用,如何返回实例B::foo();?
abstract class A
{
public static function foo()
{
$instance = new A(); // I want this to return a new instance of child class.
... Do things with instance ...
return $instance;
}
}
class B extends A
{
}
class C extends A
{
}
B::foo(); // Return an instance of B, not of the parent class.
C::foo(); // Return an instance of C, not of the parent class.
Run Code Online (Sandbox Code Playgroud)
我知道我可以这样做,但有一个更简洁的方式:
abstract class …Run Code Online (Sandbox Code Playgroud)