Posts

Showing posts with the label Operator overloading

Operator Overloading In C++

Image
Operator Overloading : For operator overloading it is important to have the knowledge of function overloading. First of all the question that arises is what is overloading? Let's consider an example: Consider a person doing his job then his boss came and assigned him the same job with a little difference. Means the job the person is doing is same but it also has some changing in it. Let's consider a program:                  void printNumber(int a) {     cout << a; } This is effective with integer arguments only. Overloading it will make it available for other types, such as char and float .          void printNumber(char a) {   cout << a; } Now the same printNumber function works for both int and char. You can consider the function as the job and the data types int and char as difference in the same job.(Both functions are doing the same job ( printing the values ) but one is...