-2
スーパークラスと子クラスの間に矢印を置くと、 は適切なコンストラクタが見つかりません(スーパークラスオブジェクトの場合はPerson内部のDate)。スーパークラスの継承とコンストラクタ
どのようなコンストラクタと継承の話ですか? スーパークラスに子クラスのコンストラクタが必要なのはなぜですか?ここ
スーパークラスのコンストラクタ:
public class Date
{
protected int _day;
protected int _month;
protected int _year;
public final int MAX_DAY = 31;
public final int MIN_DAY = 1;
public final int MAX_MONTH = 12;
public final int MIN_MONTH = 1;
public final int DEFUALT_YEAR = 4;
public Date (int day, int month, int year)
{
if((MIN_DAY <= day) && (day <= MAX_DAY) && (MIN_MONTH <= month)
&& (month <= MAX_MONTH) && (year == DEFUALT_YEAR))
{
this._day = day;
this._month = month;
this._year = year;
}
else
{
this._day = 1;
this._month = 1;
this._year = 2000;
}
}
public Date (Date other)
{
_day = other._day;
_month = other._month;
_year = other._year;
}
ここでは、子クラスのコンストラクタ:
public class Person extends Date
{
private String _first;
private String _last;
private long _id;
private Date _date;
public Person (String first, String last, long id, int d, int m, int y)
{
this._first = first;
this._last = last;
this._id = id;
Date _date = new Date(d, m, y);
}
public Person (Person other)
{
this._first = other._first;
this._last = other._last;
this._id = other._id;
this._date = other._date;
}
言語 – GiantsLoveDeathMetal
にタグを付けてください多分https://docs.oracle.com/javase/tutorial、あなたが相続にいくつかのチュートリアルをお読みください私には思えます/java/IandI/subclasses.html –