Problem Statement Design a Mother class that has the following member: • A virtual printInfo function that displays the class information which is the Class's name. Design a BabyA class that is derived from the Mother class. The BabyA class should have the following: • A print Info Design a Babys function that overrides from the base class. The BabyA class that is derived from the Mother class. The Babys function that overrides from the base class. The Babys class' print function should display only the class's name. class should have the following: • A print Info class' print function should display only the class's name. Write a program that has an array of Mother pointers. The array elements should be initialized to Mother. BabyA, and Babys objects. The program should then step through the array with a loop and call each object's printInfo function. Partial Solution #include using namespace std; class Mother { public: //declare a virtual function { } class }; { { } } }; void printInfo() { cout << "Mother class.\n"; } public void { cout << "BabyA class. \n": int main() { void printinfo :public Mother cout << "BabyB class. \n"; ptrMotherArray BabyB: public () //declare an array of the mother pointer } return 0; //POLYMOPISM //assigns values to the array //all subclasses of the Mother class are the Mother ptrMotherArray[ 0 ] = new Mother(); [1] = //calls a function from each object for(int i = 0; i < 3; i++){ ptrMotherArray[i] ptrMotherArray[ 3 ]; = new BabyA(): printInfo(): 0:
Problem Statement Design a Mother class that has the following member: • A virtual printInfo function that displays the class information which is the Class's name. Design a BabyA class that is derived from the Mother class. The BabyA class should have the following: • A print Info Design a Babys function that overrides from the base class. The BabyA class that is derived from the Mother class. The Babys function that overrides from the base class. The Babys class' print function should display only the class's name. class should have the following: • A print Info class' print function should display only the class's name. Write a program that has an array of Mother pointers. The array elements should be initialized to Mother. BabyA, and Babys objects. The program should then step through the array with a loop and call each object's printInfo function. Partial Solution #include using namespace std; class Mother { public: //declare a virtual function { } class }; { { } } }; void printInfo() { cout << "Mother class.\n"; } public void { cout << "BabyA class. \n": int main() { void printinfo :public Mother cout << "BabyB class. \n"; ptrMotherArray BabyB: public () //declare an array of the mother pointer } return 0; //POLYMOPISM //assigns values to the array //all subclasses of the Mother class are the Mother ptrMotherArray[ 0 ] = new Mother(); [1] = //calls a function from each object for(int i = 0; i < 3; i++){ ptrMotherArray[i] ptrMotherArray[ 3 ]; = new BabyA(): printInfo(): 0:
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 12PE: Some of the characteristics of a book are the title, author(s), publisher, ISBN, price, and year of...
Related questions
Concept explainers
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT