Root/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | using System; class P2 { static void Main() { cDog ob2 = new cDog(); cMammal ob1 = (cMammal)ob2; ob1.speak(); ob2.speak(); } } class cMammal { public virtual void speak() { Console.WriteLine( "Grunt" ); } } class cDog : cMammal { public override void speak() { Console.WriteLine( "woof woof" ); } } |