예제 #1
0
 public void Run()
 {
     // assign derived instance to base reference
     Telephone phone1 = new DigitalPhone();
     Telephone phone2 = new TalkingPhone();
     phone1.Ring(); // accessing the polymorphic method
     phone2.Ring(); // accessing the polymorphic method
 }
예제 #2
0
        public void Run()
        {
            // assign derived instance to base reference
            Telephone phone1 = new DigitalPhone();
            Telephone phone2 = new TalkingPhone();

            phone1.Ring(); // accessing the polymorphic method
            phone2.Ring(); // accessing the polymorphic method
        }