What do you mean by function and operator overloading in C++?

devquora
devquora

Posted On: Feb 22, 2018

 

C++ facilitates the user to specify more than one definition for a function name or an operator in the same scope. This is called function overloading and operator overloading respectively. Function overloading is primarily a feature in C++ where two or more functions can have not only the same name but also different types and numbers of parameters. Operating overloading, on the other hand, allows the user to make operators work for user-defined classes. For example, we can overload an operator such as ‘+’ in a class like String so that we can concatenate two strings by just using + instead of other descriptive functions. Other example classes where the user may overload arithmetic operators are Complex Number, Fractional Number, Big Integer, and more.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    C++ Interview Questions

    Explain what is OOP?

    Object-oriented programming (OOP) is a type of computer programming, also more commonly known as software design, in wh..

    C++ Interview Questions

    What is the difference between #import and #include in C++?

    The statement #include is used in C++ to include the source file or import the header files containing definitions of f..

    C++ Interview Questions

    What is ‘this’ pointer?

    The ‘this’ pointer is passed as a hidden argument to all the non-static member method calls and is available as a l..