Views:

Category: Entertainment

## Presentation Description

No description available.

By: PRANEEEET (39 month(s) ago)

By: imranserielkiler (39 month(s) ago)

By: imranserielkiler (39 month(s) ago)

By: imranserielkiler (39 month(s) ago)

would u like to introduce yourself??

By: PRANEEEET (39 month(s) ago)

## Presentation Transcript

### Term Paper :

Term Paper Function Overloading Presented By: Imran Ashraf Presented To: Miss Asma Basharat

### Function :

Function What is Function? A function is a block of code that performs a calculation and returns a value. Function is a self-contained block of statements that performs a coherent task whenever it is called. Once a function has been written to play a particular role, it can be called upon repeatedly throughout the program.

### Composition of Function :

Composition of Function Function is normally consist on these factors which are given below

### Calling of Function :

Calling of Function Function Call by value Function Call by Reference In call by value method, the called function creates a new set of variables and copies the values of arguments #include<iostream.h> #include<stdio.h> display(int m,int n){ m+=200; n+=200; cout<<”\n inside function m=”<<m; cout<<”\n inside function n=”<<n;} } void main(){ int i=100, j=200; cout<<”\n Before calling i=”<<i; cout<<”\n Before calling j=”<<j; display(I,j); cout<<”\n After calling j=”<<j; cout<<”\n After calling j=”<<j;} } When arguments are passed by reference the formal arguments in the called function becomes aliases to the actual arguments in the calling function. When the function is working with its own arguments, it is actually working on the original data. #include<iostream.h> #include<iostream.h> Void swap(int &p,int&q){ Int t=p; P=q; q=t;} void main(){ int a-100, b=200; cout<<”\n Before calling a=”<<a; cout<<”\n Before calling b=”<<b; }

Function Overloading Function overloading is one of the most powerful features of C++ programming language. A function is said to be overloaded when same name is given to different functions. The number of parameters, the data type of parameters, and the order of appearance these three together are referred to as the function signature. While overloading a function, the return types of the function need not differ.1. Functions differ in function signature. 2. Return types of functions need not differ.

Function Overloading You overload a function name f by declaring more than one function with the name f in the same scope. The declarations of f must differ from each other by the types and/or the number of arguments in the argument list. When you call an overloaded function named f, the correct function is selected by comparing the argument list of the function call with the parameter list of each of the overloaded candidate functions with the name f. A candidate function is a function that can be called based on the context of the call of the overloaded function name. The answer is, you have to declare functions in such a way that they differ either in terms of the number of parameters or in terms of the type of parameters they take