Article 134 - Overload vs Override Function Examples

Overloading and overriding a function is a strong part of Object Oriented Programming (OOP) languages. In C++ and Java, these forms of programming concepts enable engineers to design complex software with relative ease.

It is recommended that the reader review the concepts by reviewing the section Overriding vs Overloading Functions in Article 16 - Basic Technical Interview Questions.

Base Class

class Base{
    public:
    virtual int function( int count ){
        return count + 1;
    }
}

Overloaded Function Example

An example of Overloading a function.

class ChildOverload: public Base{
    public:
    int function( int count, int time ){
        return count + time;
    }
}

Override Function Example

An example of Overriding a function.

class ChildOverride: public Base{
    public:
    int function( int count ){
        return count + 2;
    }
}

Comments (1)

Posted by Eric Yuen at Sunday, October 13, 2013 7:48 PM

yup, this is good.

Post a comment

  • Name:
  • Post:
  • Challenge:

Register or login to post comments easier.


Vantasy World Copyright 2011 - 2017. Vantasy World is a project developed by Vantasy Online. Privacy Policy.