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


Please Help Members By Posting Answers For Below Questions

What is difference between abstraction and encapsulation?

829


How do you define social class?

829


String = "C++ is an object oriented programming language.An imp feature of oops is classes and objects".Write a pgm to count the repeated words from this scenario?

2172


What is the difference between abstraction and polymorphism?

862


Why it is called runtime polymorphism?

812


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

1905


What is new keyword in oops?

804


What is object in oop?

891


What does it mean when someone says I oop?

833


Why do we use encapsulation in oops?

768


write knight tour problem which is present in datastructure

2397


What is inheritance and how many types of inheritance?

838


What is the advantage of oop over procedural language?

855


c++ program to swap the objects of two different classes

2145


hi, this is raju,iam studying b.tech 2nd year,iam want know about group1 and group2 details, and we can studying without going to any instutions? please help me.

1758