What Does “Overloaded”/“Overload”/“Overloading” Mean?

前端 未结 8 1236
清歌不尽
清歌不尽 2020-12-09 10:33

What does \"Overloaded\"/\"Overload\" mean in regards to programming?

8条回答
  •  我在风中等你
    2020-12-09 11:05

    Others have answered what an overload is. When you are starting out it gets confused with override/overriding.

    As opposed to overloading, overriding is defining a method with the same signature in the subclass (or child class), which overrides the parent classes implementation. Some language require explicit directive, such as virtual member function in C++ or override in Delphi and C#.

    using System;
    
    public class DrawingObject
    {
        public virtual void Draw()
        {
            Console.WriteLine("I'm just a generic drawing object.");
        }
    }
    
    public class Line : DrawingObject
    {
        public override void Draw()
        {
            Console.WriteLine("I'm a Line.");
        }
    }
    

提交回复
热议问题