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
What is a class and object?
Why multiple inheritance is not allowed?
What is the difference between procedural programming and oops?
How do you achieve runtime polymorphism?
What is encapsulation example?
write a code for this. serial_number contained in the header of the file will be read , if this serial number is less than a previous serial number within a successfully processed file, or is the same as another serial number within a successfully processed file, or if the field contains anything other than 7 digits, then the file must error with the reason ‘Invalid SERIAL_NUMBER’.
What is oops?what is its use in software engineering?
Will I be able to get a picture in D drive to the c++ program? If so, help me out?
What is abstraction with example?
What is object and class in oops?
What are the important components of cohesion?
What is a null tree?
• What are the desirable attributes for memory managment?
What is polymorphism and types?
There are two base class B1,B2 and there is one class D which is derived from both classes, Explain the flow of calling constructors and destructors when an object of derived class is instantiated.