我在 C# 中编程时遇到此错误:“BankSystem.Account”不包含采用 0 个参数的构造函数
我的课程是:
首先,Account 类:
public abstract class Account : IAccount
{
private static decimal minIncome = 0;
private static int minAge = 18;
private string name;
private string address;
private decimal age;
private decimal balance;
public Account(string inName, decimal inAge, decimal inBalance, string inAddress)
{
if (AccountAllowed(inBalance, inAge))
{
name = inName;
address = inAddress;
balance = inBalance;
age = inAge;
Console.WriteLine("We created the account. \nName is " + name + " \nThe address is: "
+ address + "\nThe balance is " + balance);
}
else
{
Console.WriteLine("We cann't create the account. Please check the balance and age!");
}
}
//public CustomerAccount(string newName, decimal initialBalance)
public Account(string inName, decimal initialBalance)
{
}
其次,CustomerAccount 类:
public class CustomerAccount : Account
{
private decimal balance = 0;
private string name;
public CustomerAccount(string newName, decimal initialBalance)
{
name = newName;
balance = initialBalance;
}
public CustomerAccount(string inName, decimal inAge, decimal inBalance, string inAddress)
: base(inName, inAge)
{
// name = inName;
//age = inAge;
}
public CustomerAccount(string inName, decimal inAge)
: base(inName, inAge)
{
// name = inName;
//age = inAge;
} ......