C++ Exercise (Chapter 4 Class and Objects Manipulation)

a.Write an overloaded operator< function using the given function definition.This function returns true if the first length is less than the second length.

b.Write an overloaded operator++ function using the given function definition.This function returns true if both length is same.

c.Write the mian function  which defines an array of object Length called lens[] with the size of 4.The function must follow the following rules:
i.For each element  of lens,set the values len_inches.
ii.Check which length are same size using overloaded operator== and pirnt message to screen if the compared length  are the same.
     
                     Same length at indexes 0 and 2
                     Same length at indexes 0 and 2
                     Same length at indexes 1 and 2

iii.Check which length is the shortest and longest using overloaded operator<
 and print message to the screen
         
                     Shortest length in feet is 48 feet at index 0
                     Longest length in feet is 60 feet at index 30

Solution

Post a Comment

0 Comments