0% found this document useful (0 votes)
57 views1 page

Lab Assignment - C++ - 2 PDF

This lab assignment asks students to create a Ratio class with numerator and denominator member variables. Students must write constructors, destructors, and a copy constructor, and overload the +, -, *, /, <=, >=, ==, !=, =, +=, -=, ++ operators, as well as the << and >> stream input and output operators for the Ratio class.

Uploaded by

sunny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views1 page

Lab Assignment - C++ - 2 PDF

This lab assignment asks students to create a Ratio class with numerator and denominator member variables. Students must write constructors, destructors, and a copy constructor, and overload the +, -, *, /, <=, >=, ==, !=, =, +=, -=, ++ operators, as well as the << and >> stream input and output operators for the Ratio class.

Uploaded by

sunny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Lab Assignment

(4 May, 2020- 9 May, 2020)


Operator Overloading

Define a class ratio with numerator and denominator as member variables.
Write the constructors, destructors and copy constructor. Overload the
following operators for the same: 


• Arithmetic operators: +, -, *, /


• Relational operators: <=, >=, ==, !=


• Assignment operator: =


• Arithmetic assignment operator: +=, -=


• Pre and post increment operators: ++



• Stream input and output operators: << and >> 


You might also like