write a program for function overloading?

Answer Posted / abhishek.karal

Program illustrating function overloading

# include<iostream.h>
# include<conio.h>
int area(int side)
{
return side*side;
}
int area(int l , int b)
{
return l*b;
}

void main()
{
clrscr();
int (*p1)(int);
int (*p2)(int,int);

p1=area;
p2=area;

cout<<"Address of area(int)="<<(unsigned int)p1<<endl;
cout<<"Address of area(int,int)="<<(unsigned int)p2<<endl;

cout<<"Invoking area(int) via p1 "<<p1(20)<<endl;
cout<<"Invoking area(int,int) via p2 "<<p2(10,20);
getch();
}

Is This Answer Correct ?    57 Yes 23 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between pop and oop?

821


How Do you Code Composition and Aggregation in C++ ?

24731


write a program using c++ to implement single contiguous memory mangement techniques.display the content of the main memory after yhe allocation of jobs and percentage of the wastage of the main memory

2995


What is class and object with example?

826


What is static modifier?

848


What is meant by multiple inheritance?

951


Which language is not a true object oriented programming language?

879


What are objects in oop?

838


How do you achieve runtime polymorphism?

749


What is the point of oop?

871


write a program to find 2^n+1 ?

1794


What does no cap mean?

802


What is coupling in oop?

781


What is the purpose of enum?

774


officer say me - i am offered to a smoking , then what can you say

1852