上級 › does not implement inherited abstract member の原因と直し方 › パターン5
does not implement inherited abstract member の原因と直し方
abstractなメンバーを持つ基底クラスを継承したのに、そのメンバーをoverrideしていないと出るコンパイルエラーです。
1 abstract class Task { 2 public abstract bool IsDone(); 3 } 4 class Chore : Task { 5 public bool Done; 6 ______________________________________________ ^ 7 } 8 class Program { 9 static void Main(string[] args) { 10 Chore c = new Chore { Done = true }; 11 System.Console.WriteLine(c.IsDone()); 12 } 13 }
Program.cs(4,7): error CS0534: 'Chore' does not implement inherited abstract member 'Task.IsDone()'
空欄を埋めてビルドを通す
戻り値の型(ここではbool)も基底クラスの宣言と一致させる必要があります。
次の問題