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

Write a program to reverse a string using recursive function?

0 Answers   TCS,


What is the outcome of the line of code "cout<<abs(- 16.5);"? 1) 16 2) 17 3) 16.5

16 Answers   TCS,


what is abstract class ? when is used in real time ? give a exp

5 Answers  


Can anyone please explain runtime polymorphism with a real time example??at what ciscumstances we go for it??

1 Answers  


What is the purpose of polymorphism?

0 Answers  






What is difference between abstraction and encapsulation?

0 Answers  


How to create a comment page in C #??

2 Answers  


can we make game by using c

1 Answers   SmartData,


what is the drawback of classical methods in oops?

0 Answers  


what is the difference between <stdio.h>and "stdio.h"?

5 Answers  


what is overloading

3 Answers   MindCracker,


tell about copy constructor

3 Answers   Siemens,


Categories