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
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.
What is encapsulation with real life example?
What are different oops concepts?
What are benefits of oop?
to find out the minimum of two integer number of two different classes using friend function
What is inheritance in simple words?
What is polymorphism what are the different types of polymorphism?
Write a c++ program to display pass and fail for three student using static member function
What is encapsulation process?
What is encapsulation in oop?
How to use CMutex, CSemaphore in VC++ MFC
What is overriding vs overloading?
What is difference between polymorphism and inheritance?
What is data binding in oops?
Which type does string inherit from?