write a program for function overloading?
Answer Posted / narmadha
same function name with multiple definitions
#include <iostream.h>
void print(int i)
{
cout << " int " << i << endl;
}
void print(double f)
{
cout << " float " << f << endl;
}
void print(char* c)
{
cout << " char " << c << endl;
}
int main()
{
print(10);
print(10.10);
print("a");
return 0;
}
| Is This Answer Correct ? | 6 Yes | 2 No |
Post New Answer View All Answers
What are functions in oop?
What is class and example?
What is inheritance in oop?
What are the benefits of polymorphism?
Why is there no multiple inheritance?
How to hide the base class functionality in Inheritance?
What are objects in oop?
Why is it so that we can have virtual constructors but we cannot have virtual destructors?
What is difference between inheritance and polymorphism?
What is encapsulation and abstraction? How are they implemented in C++?
Why do we use inheritance?
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).
What is protected in oop?
What is the real life example of polymorphism?
What is the example of polymorphism?