Anda di halaman 1dari 2

ANURADHA ENGINEERING COLLEGE ,

CHIKHLI.

LABORATORY
MANUAL

2008-09
DEPTT.OF ELECTRONICS & TELECOMM.

PRACTICAL EXPERIMENT INSTRUCTION SHEET


PROGRAM TO ADD TWO NUMBERS AND CONCENTRATE AND
ALSO TWO STRINGS FUNCTIONS USING OVERLOADING.
SUBJECT : COMPUTER PROGRAMMING & APPLICATIONS.
SECOND YEAR : II (IV SEM)
EXPT NO 10

AIM: Program to add two numbers and concentrate and also two strings functions
using overloading.
OBJECTIVES:
APPARATUS :

THEORY: - Overloading refers to the use of something for the different purpose. C++
also permits overloading of functions it means that by using some functions name we can
create function on that perform a variety of different tasks. This is known as function
polynomial.
Using this concept we can design a family of functions with one function
name but different argument lists. The function would perform different operation
depending upon argument list in the functions call the count function is evoked by
checking the numbers & type of arguments but on the function types.
Declaration:int add (int a, int b); //prototype.
int add (int a, int b, int c);
double add (int p, double q);
Function calls
Count<<add (5, 10); //user prototype
Count << add (15, 10.0)
Count << add (5, 10, 15)
A function cal first matches the 3prototype having the same numbers and
same type of arguments and then all appropriate functions for execution
The selection involves following steps.
1) Compiler first tries to find exact match in the type of actual arguments are the
same and use that functions.
2) If exact match is found, the compilers use the integer promotions to the actual
arguments such as char & int.
Float to double to final match.
3) When either of them falls the compiler tries to use built in conversion to actual
parameters and then uses the functions whose match is unique to if there exists
multiple matches then computer will generates an error message for e.g.
Long square ( long n)
PREPARED BY: Mr.A.P.Bhatkar

APPROVED BY: Prof.V.T.Gaikwad, HOD

ANURADHA ENGINEERING COLLEGE ,


CHIKHLI.

LABORATORY
MANUAL

2008-09
DEPTT.OF ELECTRONICS & TELECOMM.

PRACTICAL EXPERIMENT INSTRUCTION SHEET


PROGRAM TO ADD TWO NUMBERS AND CONCENTRATE AND
ALSO TWO STRINGS FUNCTIONS USING OVERLOADING.
SUBJECT : COMPUTER PROGRAMMING & APPLICATIONS.
SECOND YEAR : II (IV SEM)
EXPT NO 10

Double Square (double x)


A function call such as square (10) will cause an error because an
int argument can be converted to either long or double there by creating ambiquary
situations as to make version of square standard be used.
4) If all steps fail then compiler will strive to use user defined conversion to find an
exact match. User defined conversion are often used in handling class objects.
Overloading of functions standard be due with caution.

RESULT:
Enter any two numbers: 6, 8
Enter any two characters: S T
Enter two strings : SACHIN _TAMBAT
Addition of numbers:
14
Joined character is:
NJ
Contained strings are: SACHIN _ TAMBAT

PREPARED BY: Mr.A.P.Bhatkar

APPROVED BY: Prof.V.T.Gaikwad, HOD