using System;
class BaseClass
{
public virtual void baseInfo()
{
Console.WriteLine("BaseClass");
}
}
class DerivedClass1 : BaseClass
{
public override void baseInfo()
{
Console.WriteLine("DerivedClass1");
}
}
class DerivedClass2 : BaseClass
{
public override void baseInfo()
{
Console.WriteLine("DerivedClass2");
}
}
class MainClass
{
static void Main()
{
BaseClass bc;
bc = new BaseClass();
bc.baseInfo();
bc = new DerivedClass1();
bc.baseInfo();
bc = new DerivedClass2();
bc.baseInfo();
}
}
0 コメント:
コメントを投稿