B02D-2015D – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  

Login
[lwa]



Exam Questions-CBSE12D-2015-B02D #PYTHON#6527    siteicon   siteicon  

Problem Statement - B02D-2015D

What is operator overloading with methods? Illustrate with the help of an example using a python code.

Solution

TC++ #6527

Operator overloading is an ability to use an operator in more than one form.

Examples:
In the following example operator + is used for finding the sum of two integers:
    a = 7
    b = 5
    print(a+b) # gives the output: 12
Whereas in the next example, shown below the same + operator is used to add two strings:
    a = 'Indian '
    b = 'Government'
    print(a+b) #gives the output: Indian Government


Share

CSKC| Created: 14-Jan-2019 | Updated: 14-Jan-2019|CBSE12D-2015









Back