ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C++  >>  OOPS
 
 


 

 
 STL interview questions  STL Interview Questions
 OOPS interview questions  OOPS Interview Questions
 C++ General interview questions  C++ General Interview Questions
Question
write a program for function overloading?
 Question Submitted By :: Sandeep
I also faced this Question!!     Rank Answer Posted By  
 
  Re: write a program for function overloading?
Answer
# 1
#include<iiostream.h>
class overload
{
public:
int max(int,int);
floatmax(float,float);
};
int overload::max(int num1,int num2)
{
if(num1>nmu2)
{
return num1;
}
else
{
return num2;
}
}
float overload::max(float num1,float num2)
{
if(num1>num2)
{
return num1;
}
else
{
return num2;
}
}
int main(90
{
overload o1;
cout<<"o1.max(5.4f,8.6f)<<endl;
cout<<"o1.max(19,34)<<endl;
}
 
Is This Answer Correct ?    3 Yes 0 No
Nekkanti Rajesh
 
  Re: write a program for function overloading?
Answer
# 2
8.6 for float
34 for int
 
Is This Answer Correct ?    1 Yes 0 No
N. Sakthi Ganesh
 
 
 
  Re: write a program for function overloading?
Answer
# 3
FYI

for overloading a function differing only by return type is 
illegal (it is legal to use different a return type with a 
different argument list, though) :
 
Is This Answer Correct ?    0 Yes 0 No
Nk
 
  Re: write a program for function overloading?
Answer
# 4
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 ?    0 Yes 0 No
Abhishek.karal
 

 
 
 
Other OOPS Interview Questions
 
  Question Asked @ Answers
 
Why and when is a virtual destructor needed?  2
Explain polymorphism? What r the types of polymorphism? pls give examples? HCL2
We have a scale and 7 balls. 1 ball is heavier than all the rest. How to determine the heaviest ball with only 3 possible weighing attempts? IBM3
What is the difference between pass by reference and pass by value? TCS6
When is it necessary to use member-wise initialization list in C++?  1
Definition of Object Oriented Programming in single line? TCS14
What is multiple inheritance ? Ness-Technologies8
what is object slicing? Wipro4
Describe the difference between a Thread and a Process?  6
How is data security provided in Object Oriented languages? ?  3
what is virtual function in c++  4
What are the advantanges of modularity  2
What is the outcome of the line of code "cout<<abs(- 16.5);"? 1) 16 2) 17 3) 16.5 TCS10
What are virtual functions?  2
Can we call a base class method without creating instance?  4
how to swap to variables without using thrid variable in java?  3
How Do you Code Composition and Aggregation in C++ ? IBM1
What is the differances between a abstract calss and interface Aviva2
What is Dynamic Polymorphism?  6
What do you mean by multiple inheritance and multilevel inheritance? Differentiate between them.  2
 
For more OOPS Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com