WHY FUCTION OVERLOADING DOSENOT RETURN A RETEN TYPE
Answer Posted / 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 View All Answers
How to handle exception in c++, For example in a functions i am assigning memory to some variables and also in next instructions in am dividing one variable also. If this functions generates a error while allocating memory to those variable and also while dividing the variable if i divide by zero then catch block how it will identify that this error has cone from perticular instruction
Give an example where we have to specifically use C programming language and C++ programming language cannot be used?
What is object in oop with example?
What is the difference between procedural programming and oops?
What is inheritance and how many types of inheritance?
How do you achieve polymorphism?
How do you use inheritance in unity?
What is encapsulation selenium?
What is constructor in oop?
can inline function declare in private part of class?
What is variable example?
What is polymorphism in oops with example?
What does no cap mean?
What is polymorphism what are the different types of polymorphism?
what is different between oops and c++