Question
The goal of this homework is get you familiar with inheritance, virtual functions, pure virtual functions, and heterogeneous containers. in C++ 1. You need to
The goal of this homework is get you familiar with inheritance, virtual functions, pure virtual functions, and heterogeneous containers. in C++
1. You need to design and implement a colorful Shape class with one pure virtual function computeArea(), two data members for the X and Y location of the object, one data member for the color (which can be black, white, or red), and one function printColor() that prints out the color.
2. You need to design and implement a Square class that needs to provide a concrete implementation of computeArea() and one additional data member for the edge length.
3. You need to design and implement a Circle class that needs to provide a concrete implementation of computeArea() and an additional data member for the radius.
4. In your main function, you need to design a heterogeneous container that holds 4 Square objects and 2 circle objects.
5. In your main function, you need to go through every element of the heterogeneous container and output their area sizes and colors.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started