Lab 9 Prelab Questions 1. Define inheritance. 2. Why do we use inheritance in C++? In other words, why is it useful? 3. Give an example of inheritance not derived from the text, notes or slides. 4. Implement your example of inheritance from #3. ---- Questions 5-8 are based on the description below: Consider a class Shape with a derived class Quadrilateral. /* Defining public members is generally bad design, we will ignore that for this question */ class Shape { public: int num_edges; // eg 3 for triangle, 4 for rectangle etc... Shape(int edges):num_edges(edges) {} }; class Quadrilateral : Public Shape { public: int type; // Rectangle = 1, Square = 2, Rhombus = 3 Quadrilateral(int qtype, int edges): Shape(num_edges), type(qtype) {} }; 5. Define a class Rectangle that derives from class Quadrilateral. 6. Define two member variables, length and breadth for this class. 7. Define a constructor for this class that will call its base class. 8. Compile the following code and find out what will print. Explain the results that you discovered. Why do you think this was the result? int main() { Rectangle rect; cout << sizeof(rect); } --- 9. Think about what the following class with print: class EmptyClass { }; int main() { EmptyClass empty; cout << sizeof(empty); } Did the class print what you expected? Explain your answer. 10. Describe protected inheritance. Why would one use this? Provide an example that supports your explanation.