Lab Report 12
Lab Report 12
Registration FA21-BEE-128
Number
Class BEE-3A
Example 2
This example is about binary operators. Binary operators contain two operands. It includes
addition (+), subtraction (-) and other operators. In this example, we overloaded the addition
operator. We make a class of box having length, breath and height as its data members.
Link: https://onlinegdb.com/mzthU0bxR
Example 3
This example is about stream operators. Stream operators contains insertion and extraction
operators. In this example, we make a class of Date. We use the insertion operator. We declared
the overloaded << operator function as a friend of class Date to get an access of the private data
within a Date object.
Link: https://onlinegdb.com/PrdUd2AMY
Task 5.1
In this task, we make a base class of counter. We use the increment (++) operator. We
overloaded the increment operator for the counter class. We make the object of the counter class
and uses it as a loop counter for printing a table in main function.
Link: https://onlinegdb.com/yx13ARwsb-
Task 5.2
In this task, we use binary operator of addition (+). We make a class of complex. It contains the
real and imaginary part separately. We overload the + operator for this class. The class contains
the get and show data functions who take the values from the user and display them.
Link: https://onlinegdb.com/4tOHWJEHp
Task 5.3
In this task, we create a class of distance. It has feet and inches as data members. We uses %
operator which divides the given numerator by the denominator to find a result. In this program,
through % operator when we divide any number with 12, the value of the quotient will come
under the feet and the value of remainder will come under the inches.
Link: https://onlinegdb.com/VkacMImG9
Task 6.1
In this task, we make a calculator for the complex numbers using all types of operators. We
make a class of complex numbers. We overloaded all the operators that are ++, --, +, -, /, *, >>,
<<. We make functions for each operator and in its definition, we include both its real and
imaginary parts.
Link: https://onlinegdb.com/aNb2Gqy8i