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


Please Help Members By Posting Answers For Below Questions

class type to basic type conversion

2089


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?

1619


What is difference between oop and pop?

870


What are the data types in oop?

825


Where You Can Use Interface in your Project

1618


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?

2151


What is oops and its features?

827


What are two types of polymorphism?

803


write string class as your own class in java without using any built-in function

2210


Can a varargs method be overloaded?

812


Can we create object of abstract class?

819


What is the importance of oop?

833


What does sksksk mean in text slang?

1835


What are different types of JVM's? for example we use dalvik jvm for android then what about the remaining operating systems?

1889


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(); }

2206