Tag:polymorphic

  • Three Object-Oriented Characteristics

    Time:2019-8-11

    Three characteristics of object-oriented: encapsulation, inheritance and polymorphism.   1. Inheritance:That is to let one type of object have the properties of another type of object.Method. After inheritance, the subclass owns the attributes and methods of the parent class.   2. Encapsulation:That is to bundle data and code together to prevent external interference.   3. […]

  • The Realization and Principle of C++ Polymorphism

    Time:2019-8-10

    The polymorphism of C++ can be summarized in one sentence: add virtual keyword to the function of the base class, and override the function in the derived class. At run time, the corresponding function will be called according to the actual type of the object. If the object type is a derived class, the function […]

  • Virtual Method and Polymorphism

    Time:2019-6-8

    class Program { static void Main(string[] args) { //Dog dog = new Dog(); Pet dog = new Dog (“DD”); // Create an instance of the base class Pet pointing to the derived class Dog //dog.Name = “DD”; Dog. Speak (); // Here is the call to the virtual method Speak () of the Pet class, […]