我正在从另一个类继承的类,但我得到一个编译器错误说:“找不到符号构造函数Account()”。基本上我想要做的是创建一个从账户账户延伸的InvestmentAccount类,旨在与提取/存款的方法保持平衡,InvestmentAccount类似,但余额存储在股票中,股票价格决定了如何许多股票是以特定金额存入或提取的。以下是前几行(约编译器在其中指出的问题)子类InvestmentAccount的:继承在Java中 - “无法找到符号构造函数”
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)举行。现在,这里的超类账户的第几行:
public class Account
{
private Person customer;
protected int balanceInPence;
public Account(Person customer)
{
this.customer = customer;
balanceInPence = 0;
}
// etc...
没有任何理由为什么编译器不只是从Account类阅读的符号构造的帐户?还是我需要为InvestmentAccount中的Account定义一个新的构造函数,它告诉它继承一切?
感谢
正如我规则,我总是把super()调用放在我的构造函数中,当适用时。 – eljenso 2009-02-04 10:41:56