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...
icon
Related questions
Question
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 printInfo function that overrides from the base class. The BabyA
Design a BabyB class that is derived from the Mother class. The Babys
class' print function should display only the class's name.
class should have the following:
• A print Info function that overrides from the base class. The BabyB
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 <iostream>
using namespace std;
class Mother
public:
//declare a virtual function
}
{
{
{
class
}
}
void printInfo()
cout << "Mother class.\n";
public
cout << "BabyA class. \n";
}
}
int main()
void printInfo()
void
{
cout << "BabyB class. \n";
public Mother
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 ];
BabyA();
printInfo();
0:
Transcribed Image Text: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 printInfo function that overrides from the base class. The BabyA Design a BabyB class that is derived from the Mother class. The Babys class' print function should display only the class's name. class should have the following: • A print Info function that overrides from the base class. The BabyB 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 <iostream> using namespace std; class Mother public: //declare a virtual function } { { { class } } void printInfo() cout << "Mother class.\n"; public cout << "BabyA class. \n"; } } int main() void printInfo() void { cout << "BabyB class. \n"; public Mother 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 ]; BabyA(); printInfo(); 0:
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Class
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT