Functions overloading, C/C++ Programming

Functions Overloading

This a capability in which a C++ program can have several functions performing similar tasks on different data types. When an overloaded function is called, C++ selects the proper function by examining the
number, types and order of the arguments in the call.

Overloaded functions are distinguished by their signatures. A signature is a combination of function's name, and its parameter types.

The compiler encodes each function identifier with the number and types of its parameters to enable type safe linkage. Type safe linkage ensures that the proper overloaded function is called and the arguments conform to the parameters.

Creating overloaded functions with identical parameter list but different return types is a syntax error.


Write a C++ program that uses overloaded functions to find squares of both an integer and double numeric values.

using namespace std;
int square(int);

double square(double);
int square  (int num)

return num*num;



double square  (double num)

return num*num;



int main  ()

int number1;


double number2;


cout<<"Enter an integer number"<


cout<<"Enter a floating point number"<>number2;

cout<<"The square of the integer number is: "

cout<<"The square of the floating number is: "

return  0;

Posted Date: 8/21/2012 11:52:27 AM | Location : United States

Related Discussions:- Functions overloading, Assignment Help, Ask Question on Functions overloading, Get Answer, Expert's Help, Functions overloading Discussions

Write discussion on Functions overloading
Your posts are moderated
Related Questions
Control Flow The control flow statements are used when it is needed that the flow of the program is to be changed after taking some decision. This control flow statement theref

Need help with C network program

Program is to create a file student.dat: Program is to create a file student.dat which contains all name, roll_no,marks(5 sub) and percentage   class student    {

source code for padovan string

L is a text and can be composed of any of the characters {, }, (, ) , and P, where P will represent the instruction. L will contain single spaced characters where each character

write a c++ program for minimum shelf downloads

Raj is a newbie to the programming and while learning the programming language he came to know the following rules: · Each program must start with ''{'' and end with ''}''

Write a C function to solve the system of linear equations A x = y where A is an N by N matrix in the format of pointer-to-pointers and y is a vector in the format of a pointer. Th

Inheritance and Reuse Consider a car manufacturing company. When they require building a new car, they have two choices. They can start from the scratch, or they can change an