What is difference between function overloading and overriding?



What is difference between function overloading and overriding?..

Answer / 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

More OOPS Interview Questions

WAP to generate 2n+1 lines of the following pattern on the computer screen:

2 Answers  


How to overload new operator in c++

2 Answers  


what is an qt4 interface?

1 Answers   IBM,


Why is oop better than procedural?

0 Answers  


swapping program does not use third variable

5 Answers   TCS,






How do you make derived class as an abstract class?

1 Answers   Convergys, TCS,


what is the difference between a package and a software?

3 Answers  


What is overriding in oops?

0 Answers  


Generally, in all C++ programs, texts are in white colour. Can we change the colour of the text(either input or output or both)? If so, help me out.

1 Answers  


Write a program to implement OOPS concepts such as inheritance, polymorphism, friend function, operator overloading?

0 Answers   TCS,


What is encapsulation c#?

0 Answers  


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

0 Answers  


Categories