上級 › does not implement inherited abstract member の原因と直し方 › パターン2
does not implement inherited abstract member の原因と直し方
abstractなメンバーを持つ基底クラスを継承したのに、そのメンバーをoverrideしていないと出るコンパイルエラーです。
1 abstract class Vehicle { 2 public abstract void Drive(); 3 } 4 class Car : Vehicle { 5 _____________________________________________________________________ ^ 6 } 7 class Program { 8 static void Main(string[] args) { 9 Car c = new Car(); 10 c.Drive(); 11 } 12 }
Program.cs(4,7): error CS0534: 'Car' does not implement inherited abstract member 'Vehicle.Drive()'
空欄を埋めてビルドを通す
publicかoverrideのどちらかが欠けても、抽象メンバーの実装としては認められません。
次の問題