我在PHP中遇到了OOP中的一個問題。我試圖實現一個抽象的父類方法,並從子類,我必須使用它與可變數目的參數。 這裏是拋出的錯誤: PHP Fatal error: Declaration of Square::getArea($length) must be compatible with Shape::getArea() 及其類別: abstract class Shape {
abs
我有下面的代碼,我不斷收到錯誤必須有一個身體,因爲它沒有標記爲抽象的extern或部分。 public interface Shape{
int GetArea();
}
public class shape:Shape{
int height;
int width;
int radius;
int GetArea();
}
class
我有一個抽象類,只有一個抽象方法;和一些實施班(約6人)。 該方法返回一個「需要」兩個參數的對象。 但是,在某些情況下,只需要兩個參數中的一個。 有沒有一種優雅的方式來實現這種情況? (而不是返回該參數爲空) public class NormResult {
protected List<String> normWords;
protected List<String> un
我有一個抽象類,併爲它執行兩個實現。 public abstract class Person{
public abstract string GetName();
}
public class Doctor : Person{
public override string GetName()
{
return "Doctor";
}
}