我在這段代碼上得到一個錯誤,我無法弄清楚如何糾正它。具有參數構造函數的基類的繼承
public Track(string sKind, string tName, string loc,
string cName, string aSeason,
int numPlayed, int numWins, int numPlayers)
: base(sKind, tName, loc, cName, aSeason, numPlayed, numWins)
{
numOfPlayers = numPlayers;
}
這是錯誤:
CS7036 There is no argument given that corresponds to the required formal parameter 'numPlayers' of 'Football.Football(string, string, string, string, string, int, int, int)' Track
我傳遞與調幅參數爲基類的構造函數。
'base()'有8個參數,你傳遞的只是7個。 – Sinatr
你是否在''base(...',或者你實例化Track()'的那一行上得到那個錯誤? –
你應該考慮重構你的代碼,以減少構造函數參數的數量。最佳實踐建議不超過3 –