HOW IS METHOD OVERRIDING DIFFERENT FROM METHOD OVERLOADING?

Pushpendra Singh

Total Post:241

Points:1205
Posted by  Pushpendra Singh
C# 
C#
 1109  View(s)
Ratings:
Rate this:
  1. Pushpendra Singh

    Post:241

    Points:1205
    How is method overriding different from method overloading?

    When overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same name within the class.

  1. Pushpendra Singh

    Post:241

    Points:1205
    How is method overriding different from method overloading?

    When overriding, you change the method behavior for a derived class.
    e.g Clas x
    {
    Virtual void sum(int a)
    {
    }
    }

    Class B:x
    {
    public overrid void sum(int a)
    {

    }
    }

    Overloading simply involves having a method with the same name within the class.

    Example for Over loading

    Class A
    {
    class b()

    {

    }
    class b(int a)
    {
    }
    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!