我正在研究一个从另一个类继承的类,但我收到一个编译器错误,提示“找不到符号构造函数 Account()”。基本上,我要做的是创建一个从 Account 扩展的类 InvestmentAccount - Account 旨在通过提取/存入资金的方法保持余额,而 InvestmentAccount 类似,但余额存储在股票中,股价决定如何给定特定数量的资金,许多股票被存入或取出。这是子类 InvestmentAccount 的前几行(编译器指出问题的地方):
public class InvestmentAccount extends Account
{
protected int sharePrice;
protected int numShares;
private Person customer;
public InvestmentAccount(Person customer, int sharePrice)
{
this.customer = customer;
sharePrice = sharePrice;
}
// etc...
Person 类保存在另一个文件 (Person.java) 中。现在这里是超类 Account 的前几行:
public class Account
{
private Person customer;
protected int balanceInPence;
public Account(Person customer)
{
this.customer = customer;
balanceInPence = 0;
}
// etc...
为什么编译器不只是从 Account 类中读取 Account 的符号构造函数?或者我是否需要在 InvestmentAccount 中为 Account 定义一个新的构造函数,告诉它继承所有内容?
谢谢