161k views
5 votes
1. Briefly explain the concept of signature of a function, in a function declaration. What signature components are crucial for distinguishing Overloaded Functions. Provide example function declarations demonstrating function overloading

User Phenry
by
5.7k points

1 Answer

7 votes

Answer:

Function signature can be defined as a combined term used to refer to the function name, function return type, no of arguments , type of arguments.

Step-by-step explanation:

The signature of function is seen as a combined term used to refer to the function name, function return type, number of arguments , type of arguments.

When overloaded functions is been defined, they are different in numbet of arguments or type of argument passed.

To understand this better refer to the program code below.

C++ code.

#include <iostream>

using namespace std;

int multiply(int a, int b)

{

cout << a*b <<endl;

return 0;

}

int multiply(int a, int b, int c)

{

cout << a*b*c <<endl;

return 0;

}

int main()

{

//function with two arguments passed

multiply(3, 50);

//function with three arguments passed . It is different in number of arguments passed. Thus here function signature is different

multiply(4, 20, 10);

}

User Sinister Beard
by
5.6k points