Read without ads and support Scribd by becoming a Scribd Premium Reader.
 
9
Virtual Functions - new andoverride
Every breath you take,And every move you makeEvery bond you break, every step you takeI’ll be watching you-Every Breath You Take,Sting New and Override Methodsa.csclass zzz{ public static void Main(){yyy a = new yyy();xxx b = new xxx();yyy c = new xxx();a.abc();a.pqr();a.xyz(); b.abc();b.pqr();b.xyz();
 
c.abc();c.pqr();c.xyz();}}class yyy{ public void abc(){System.Console.WriteLine(“yyy abc”);} public void pqr(){System.Console.WriteLine(“yyy pqr”);} public void xyz(){System.Console.WriteLine(“yyy xyz”);}}class xxx : yyy{ public void abc(){System.Console.WriteLine(“xxx abc”);
 
} public void pqr(){System.Console.WriteLine(“xxx pqr”);} public void xyz(){System.Console.WriteLine(“xxx xyz”);}}Compiler Warninga.cs(30,13): warning CS0108: The keyword new is required on 'xxx.abc()' because it hidesinherited member 'yyy.abc()'a.cs(34,13): warning CS0108: The keyword new is required on 'xxx.pqr()' because it hidesinherited member 'yyy.pqr()'a.cs(38,13): warning CS0108: The keyword new is required on 'xxx.xyz()' because it hidesinherited member 'yyy.xyz()'Outputyyy abcyyy pqr yyy xyzxxx abcxxx pqr xxx xyzyyy abc
Search History:
Searching...
Result 00 of 00
00 results for result for
  • p.
  • Notes
    Load more