What is function overloading and operator overloading?
Answer Posted / sagar sapkota
A function is overloaded when same name is given to different function. However, the two functions with the same name will differ at least in one of the following.
a) The number of parameters
b) The data type of parameters
c) The order of appearance
These three together are referred to as the function signature.
For example if we have two functions :
void foo(int i,char a);
void boo(int j,char b);
Their signature is the same (int ,char) but a function
void moo(int i,int j) ; has a signature (int, int) which is different
While overloading a function, the return type of the functions need to be the same.
In general functions are overloaded when :
1. Functions differ in function signature.
2. Return type of the functions is the same.
Operator overloading allows existing C++ operators to be redefined so that they work on objects of user-defined classes. Overloaded operators are syntactic sugar for equivalent function calls. They form a pleasant facade that doesn't add anything fundamental to the language (but they can improve understandability and reduce maintenance costs).
Is This Answer Correct ? | 8 Yes | 2 No |
Post New Answer View All Answers
assume the program must insert 4 elements from the key board and then do the following programs.sequential search(search one of the elements),using insertion sort(sort the element) and using selection sort(sort the element).
What is polymorphism what is it for and how is it used?
How do you use inheritance in unity?
How to use CMutex, CSemaphore in VC++ MFC
Question: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date.
What is coupling in oop?
explain sub-type and sub class? atleast u have differ it into 4 points?
What is abstraction encapsulation?
How is class defined?
What is the difference between inheritance and polymorphism?
Why do we use class?
What is a class and object?
What is encapsulation example?
What does no cap mean?
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?