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
What is inheritance write a program to show use of inheritance?
What is encapsulation process?
What is abstraction with example?
any one please tell me the purpose of operator overloading
What is a class and object?
What does I oop mean?
can inline function declare in private part of class?
Which language is not a true object oriented programming language?
What is interface in oop?
is there any choice in opting subjects like 4 out of 7
Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)
What is Difeerence between List obj=new ArrayList(); and ArrayList obj=new ArrayList()?
How to use CMutex, CSemaphore in VC++ MFC
How is polymorphism achieved?
Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.