(a) Write code to create ‘Shape’ class and include following: 1. Create these private data members in Shape class: width (float), length (float), name (string) 2. Create wrappers (getters/setters) for each data member 3. Create a constructor that initialises data members and a destructor that outputs data members 4. Create a copy constructor in the class and use it in main function 5. Include meaningful composition in the Shape class and use it in main function (b) Consider the class in part a, and overload the greater-than-equal-to operator (>=) in the Shape class. The overloading function should be able to compare 2 class objects of Shape class such that return ‘true’ if the object on the left side is greater than or equal to the object on the right side and return ‘false’ if not. The comparison should be on the basis of the area of compared shapes, i.e. A = width * length. Also use the overloaded operator in the main function.
(a) Write code to create ‘Shape’ class and include following:
1. Create these private data members in Shape class: width (float), length (float), name (string) 2. Create wrappers (getters/setters) for each data member 3. Create a constructor that initialises data members and a destructor that outputs data members 4. Create a copy constructor in the class and use it in main function 5. Include meaningful composition in the Shape class and use it in main function (b) Consider the class in part a, and overload the greater-than-equal-to operator (>=) in the Shape class. The overloading function should be able to compare 2 class objects of Shape class such that return ‘true’ if the object on the left side is greater than or equal to the object on the right side and return ‘false’ if not. The comparison should be on the basis of the area of compared shapes, i.e. A = width * length. Also use the overloaded operator in the main function.
Step by step
Solved in 3 steps with 1 images