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

What is polymorphism give a real life example?

0 Answers  


what is the difference between class and structure in C++?

9 Answers   Aspire, IBS, TCS,


1.what are two type of classe members called? 2.what is data hiding and data encapsulation? 3.how do you make a class member visible aouside its class? 4.what is the default visibility of a class data member? 5.what are the advantages of oop over the structured programing?

6 Answers  


Write a program to accept a number and to print numbers in pyramid format? for eg:for a no. 5 1 212 32123 4321234 543212345

7 Answers  


Why is destructor used?

0 Answers  






How to overload new operator in c++

2 Answers  


what does exactly the linker do?

1 Answers  


write a program that takes input in digits and display the result in words from 1 to 1000

0 Answers   Wipro,


what are the ways in which a constructors can be called?

0 Answers  


How would you stop a class from class from being derived or inherited.

18 Answers   Ness Technologies,


what is the definition of incapsulation

2 Answers  


What do you mean by variable?

0 Answers  


Categories