Lesson 19 of 24

Operator Overloading

10 min 35 XP

+ - == < പോലുള്ള operators-ന് നിങ്ങളുടെ class-നായി അർത്ഥം നൽകാം. << overload ചെയ്താൽ cout << object അങ്ങനെ തന്നെ പ്രവർത്തിക്കും.

Example: edit me and press Run

Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.

Challenge

+35 XP

രണ്ട് fractions കൂട്ടി GCD ഉപയോഗിച്ച് ഫലം ലഘൂകരിക്കുന്ന operator+-ഉം "a/b" print ചെയ്യുന്ന operator<<-ഉം ഉള്ള class Fraction എഴുതൂ. main()-ൽ a b c d വായിച്ച് a/b + c/d print ചെയ്യൂ. Input: 1 2 1 3 → Output: 5/6

Output Loading C++ (first time takes a few seconds)
Press Run to see the result here.