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
Why is static class not inherited?
What is object and class in oops?
Why is oop useful?
What are the three main types of variables?
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
What is multilevel inheritance explain with example?
What is cohesion in oop?
Describe these concepts: Polymorphism, Inheritance and Abstraction.
What do you mean by Encapsulation?
What is difference between multiple inheritance and multilevel inheritance?
Which language is pure oop?
What is inheritance and how many types of inheritance?
What is destructor oops?
Why do we need oop?
What is overriding in oops?