나는 나에게이 문제를 알려주는 오류 메시지 데 대한 정의가 포함되어 있지 않습니다."개체" "이름"
여기 내 코드입니다 :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BankAccounts
{
class account
{
protected string name;
protected float balance;
public account(string n, float b)
{
name = n;
balance = b;
}
public void deposit(float amt)
{
balance -= amt;
}
public void display()
{
Console.WriteLine("Name: {0}. Balance: {1}.", name, balance);
}
}
class savingaccount : account
{
static int accno = 1000;
int trans;
public savingaccount(string s, float b) : base(s, b)
{
trans = 0;
accno++;
}
public void withdraw (float amt)
{
if (trans >= 10)
{
Console.WriteLine("Number of transactions exceed 10.");
return;
}
if (balance - amt < 500)
Console.WriteLine("Below minimum balance.");
else
{
base.withdraw(amt);
trans++;
}
}
public void deposit(float amt)
{
if (trans >= 10)
{
Console.WriteLine("Number of transactions exceed 10.");
return;
}
base.deposit(amt);
trans++;
}
public void display()
{
Console.WriteLine("Name: {0}. Account no.: {1}. Balance: {2}", name, accno, balance);
}
}
class currentaccount : account
{
static int accno = 1000;
public currentaccount(string s, float b) : base(s, b)
{
accno++;
}
public void withdraw(float amt)
{
if (balance - amt < 0)
Console.WriteLine("No balance in account.");
else
balance -= amt;
}
public void display()
{
Console.WriteLine("Name: {0}. Account no.: {1}. Balance: {2}.", name, accno, balance);
}
}
}
그것을 인식하지 않는 이유를 이해하지 않습니다. 클래스 saveaccount의 메소드입니다.
'계정'에는'.withdraw' 메소드가 없습니다. (클래스 이름을 대문자로 표시하는 것이 가장 좋습니다.) 파생 클래스에는 기본 클래스에'.withdraw'에 대한 서명을 포함하지 않는 것이 좋습니다. ? 이 코드를 어떻게 사용하고 있는지 게시 할 수 있습니까? 오류 메시지는 내가 볼 수있는 한 정확합니다. –
이 메소드들은 실제로'virtual' /'override', btw -와 같고 보통 "입금"하지 않습니다. –