Difference between overriding and overloading

Welcome to Toppersarena.com Forums Computer Language Arena Difference between overriding and overloading

This topic contains 0 replies, has 0 voices, and was last updated by Admin admin 5 years, 9 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1845
    Admin
    admin
    Keymaster

    Difference between overriding and overloading

    Overriding – same method names with same arguments and same return types associated in a class and its subclass.

    Example:

    class CSuper

    {

    null print ( string _name)

    {

    print “Hello” + _name;

    }

    };

    class CDerived

    {

    null print ( string _name)

    {

    print “Hello” + _name + “from Derived”;

    }

    };

    Overloading – same method name with different arguments, may or may not be same return type written in the same class itself.

    Example:

    class CClass

    {

    string print( int i);

    string print(int i, char c);

    }

    #3225
    Admin
    admin
    Keymaster

    You can refer or click here.

    #3226
    Admin
    admin
    Keymaster

    You can refer or click here.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.