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 can you overcome the diamond problem in inheritance?
What is abstraction in oop?
#include
Why do we need oop?
Why oops is important?
What is oops?what is its use in software engineering?
Prepare me a program for the animation of train
if i have same function with same number of argument but defined in different files. Now i am adding these two files in a third file and calling this function . which will get called and wht decide the precedence?
What is difference between inheritance and polymorphism?
Can we define a class within the interface?
What are properties in oop?
What is polymorphism give a real life example?
What is class and object with example?
write a code for this. serial_number contained in the header of the file will be read , if this serial number is less than a previous serial number within a successfully processed file, or is the same as another serial number within a successfully processed file, or if the field contains anything other than 7 digits, then the file must error with the reason ‘Invalid SERIAL_NUMBER’.
write a code for this:trailer recordId contains a value other than 99, then the file must error with the reason ‘Invalid RECORD_ID’(User Defined Exception).