We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 17
! * y > |
Operator Overloading and Type Conversions
(2.s) What is operator overloading ? Explain with suitable oul OR
Explain operator overloading with illustration. Write the advantages of Roe
overloading.
Ans.:
1) Theliieeh to an operator is called as operator
overloading. - ae
2) InC+t,
types. v eee,
3) For instance, C+4gpenmmitsitojadchitwowariables ofuserdefinedsdatartypes with homes
(GRUARESTRSBABIC HYPER. This means that C++ has theabili i (
a special meaning for a data type. This
4) Operator overloading (PRGWideSTaMExibleyoption for thelereationjofmnewdefinitionsyfor
most of the C++ operators.
@ scanned with OKEN Scanner8)
Ans.
y
When an
+s ben
Te deeamadaonaasto an oper,
Following program shows overloaded + operator
eg. /Finerement counter variable with ++ operator
fincludeciostreamh>
class counter
f
private
int count;
public:
counter ()
{count = 0
int get count)
{return count)
void operator ++()
feount ++)
‘
void main ()
{counter C1, C2 |
cout <'C1 = "