What is difference between function overloading and overriding?

Answer Posted / niraj verma

It is possible in C++ to use the save function name for the
no of lines for different intention. Defining multiple
function with same name is know as function overloading or
function polymorphism.

Polymorphism means one function having many forms.
The overloading function must be different in its argument
list and with different data types.

Example:
#include<iostream.h>
#include<conio.h>
int square (int);
float square (float);
void main()
{
int a = 5;
float b = 2.5;
clrscr();
cout<<"square = "<<square(a);
cout<<"\n square = "<<square(b);
getch();
}
int square(int s)
{
return (s*s);
}
float square (float j)
{
return (j*j);
}

Overloading;

Is This Answer Correct ?    9 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program to compute for numeric grades for a course. The course records are in a file that will serve as the input file. The input file is in exactly the following format: Each line contains a student's first name, then one space, then ten quiz scores all on one line. The quiz scores are in whole number and are separated by one space. Your program will take it input from this file and sends it output to a second file. The data in the output file will be exactly the same as the data in the input file except that there will be one additional number (of type double) at the end of each line. This number will be the average of the student's ten quiz scores. Use at least one function that has file streams as all or some of its arguments.

2845


What is encapsulation with real life example?

798


What are different oops concepts?

793


What are benefits of oop?

895


to find out the minimum of two integer number of two different classes using friend function

1890


What is inheritance in simple words?

830


What is polymorphism what are the different types of polymorphism?

762


Write a c++ program to display pass and fail for three student using static member function

3106


What is encapsulation process?

798


What is encapsulation in oop?

804


How to use CMutex, CSemaphore in VC++ MFC

4550


What is overriding vs overloading?

807


What is difference between polymorphism and inheritance?

827


What is data binding in oops?

841


Which type does string inherit from?

858