Abstract methods are implemented only when declarations are not implemented, and must be implemented in subclasses. Virtual methods are sound and implemented, and can be overwritten in subclasses, or the default Implementation of parent classes can be used without overwriting. Virtual methods are implementedCode No abstract method, Abstract classes cannot be instantiated. They can only be instantiated to implement the derived classes of all abstract methods. An abstract method is a virtual method. The abstract method is not implemented. Its existence is only a unified interface for the derived class. The derived class should implement this method. If you write a base class, it will never be implemented, you should define one or more methods in this class Abstract method. Abstract methods are implemented only when declarations are not implemented, and must be implemented in subclasses. Virtual methods are sound and implemented, and can be overwritten in subclasses, or the default Implementation of parent classes can be used without overwriting. Add one point Only abstract methods can be declared in abstract classes. Learning In fact, you must first understand that the virtual method is closely related to polymorphism. The virtual method allows the derived class to completely or partially rewrite the method of this class. You need to write the method body. Abstract classes can contain abstract methods and general methods. abstract classes cannot be new. abstract methods are just a definition and there is no method body, that is, there is no {}. Do not write content in them. Both of them are similar in that they are overwritten. |