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
What are main features of oop?
What do you mean by abstraction?
What are the 3 pillars of oop?
What are the types of abstraction?
What are functions in oop?
What is super in oop?
What is encapsulation in simple terms?
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).
They started with the brief introduction followed by few basic C++ questions on polumorphism, inheritance and then virtual functions. What is polymorphims? How you will access polymorphic functions in C? How virtual function mechanism works?
What are the 4 pillars of oop?
What is an interface in oop?
Why can't we have instance(stack) of a class as a member of the same class like eg.Class A{A obj;} as we can have self refential pointer
Advantage and disadvantage of routing in telecom sector
What is abstraction in oop with example?
What is the main purpose of inheritance law?