WHY FUCTION OVERLOADING DOSENOT RETURN A RETEN TYPE

Answers were Sorted based on User's Feedback



WHY FUCTION OVERLOADING DOSENOT RETURN A RETEN TYPE..

Answer / subhashish sen

I think the Question is wrong !!!!!The Question would have
been like this..

Why Function Overloading does not depend on the return type?

Ans : Function Overloading does not depend on the return
type but it depends on number, type and order of arguments
of function..

In this case Overloading Possible
-----------------------------------
Ex : int fun(int a,int b){}
int fun(int x,float y){}

In this case Overloading is not possible
---------------------------------------
int fun(int a,int b){}
float fun(int x,float y){}

The reason is..while invoking these function its not
necessary to get the return value always,means if you don't
get the return value it also works...But this wont be
possible for no,type or order of arguments..

If you need further clarification reply me....

Is This Answer Correct ?    12 Yes 10 No

WHY FUCTION OVERLOADING DOSENOT RETURN A RETEN TYPE..

Answer / manjunathtek

Function overloading has a return type...

Ex:
#include<iostream>
using namespace std;
//Function 1:

int max(int a, int b)
{
return (a>b)? a:b;
}

//Function 2:

float max(float a, float b)
{
return(a>b)? a:b;
}

int main()
{
int c;
float d;
c=max(5,4); //will display 5
cout<<c<<endl;
d=max(3.14,6.15); //will display 6.15
cout<<d<<endl;
return 0;
}

Important Concepts in Fn. Overloading:
a) Fun Overloading depends upon the type/number/order in
which the arguments are passed...
b) Fun Overloading can take place for a function which is
within the same scope... (i.e.) both function 1:, and
Function 2: should be in the same { ...} (both the
functions are within main() (i.e. same scope)...

Is This Answer Correct ?    5 Yes 4 No

Post New Answer

More OOPS Interview Questions

Can we have a private virtual method ?

8 Answers   Ness Technologies,


What is object in oops?

0 Answers  


What causes polymorphism?

0 Answers  


What is persistence in oop?

0 Answers  


advantage and disadvantage in c++>>oops and what are the questions ask for interview in c++>>oops. could you tell me or reply me

0 Answers  






What is the differances between a abstract calss and interface

5 Answers   Aviva, Symphony,


What is abstraction example?

0 Answers  


Why do pointers exist?

0 Answers  


what is virtual function?

3 Answers  


What does I oop mean?

0 Answers  


1. Strong name 2. how to prevent a class from being inherited 3. delegates 4. default modifier for interface 5. default modifier for class 6. base class for exception 7. diff bet trigger and view in sql 8. how to exchange values from one page to another page 9. can multiple catch block ll be executed at same time 10. can u store different data types in an array & array list 11. when we ll use trigger 12. try,catch,finally usage

2 Answers  


what is object slicing

3 Answers   TCS,


Categories