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
class type to basic type conversion
They started with the brief introduction followed by few basic C++ questions on polumorphism, inheritance and then virtual functions. What is polymorphims? How you will access polymorphic functions in C? How virtual function mechanism works?
What is difference between oop and pop?
What are the data types in oop?
Where You Can Use Interface in your Project
String = "C++ is an object oriented programming language.An imp feature of oops is classes and objects".Write a pgm to count the repeated words from this scenario?
What is oops and its features?
What are two types of polymorphism?
write string class as your own class in java without using any built-in function
Can a varargs method be overloaded?
Can we create object of abstract class?
What is the importance of oop?
What does sksksk mean in text slang?
What are different types of JVM's? for example we use dalvik jvm for android then what about the remaining operating systems?
What is Difference Between Inheritance and creating object and getting data? means Class A extends B{ B.getMethod();} (OR) Class A{ b obj=new B(); obj.getMethod(); }