是多态还是变态,请指教
class SecondExp
{ public int firstMethod()
{ return(secondMethod()*thirdMethod()); }
public int secondMethod()
{ return(10); }
public int thirdMethod()
{ return(20); } }
class DerivedClass : SecondExp
{
public new int secondMethod()
{ return (30); }
}
class Test
{
public static void Main()
{
//第一种:
SecondExp objDerived = new DerivedClass();
objDerived.secondMethod(); //注意这种方法
//第二种:
DerivedClass objDerived = new DerivedClass();
objDerived.secondMethod(); //注意这种方法
System.Console.WriteLine(objDerived.firstMethod());
}
}