Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Overloading vs Overridding

    • 0
    • 1
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 559
    Comment on it

    Overloading :

    • Same function name with different parameters/signatures.

    • It is compile time polymorphism.

    • It occurs in a same class methods.

    • It is a static/compile time binding.

    For e.g:

    int sample() 
    {
         cout<<"no arguments function";
     }
    
    int sample(int a)
    {
         cout<<"one arguments function";
     }
    int sample(double a)
    {
         cout<<"arguments type changed";
     }
    int sample(int a, double b){
    {
         cout<<"two arguments function";
     }
    

    Overriding :

    • Same function name with same parameters/signatures.

    • It is runtime time polymorphism.

    • It occurs between super and sub class methods.

    • It is a dynamic/ run time binding.

    For e.g:

    class Base
    {
     public:
     void show()
     {
      cout << "Base class";
     }
    };
    class Derived:public Base
    {
     public:
     void show()
     {
      cout << "Derived Class";
     }
    }
    

 1 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: