1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
JulsSmile [24]
2 years ago
8

Define a member function PrintAll() for class PetData that prints output as follows. Hint: Make use of the base class' PrintAll(

) function.
Name: Fluffy, Age: 5, ID: 4444
Given this code:

#include
#include
using namespace std;

class AnimalData {
public:
void SetName(string givenName) {
fullName = givenName;
};
void SetAge(int numYears) {
ageYears = numYears;
};
// Other parts omitted

void PrintAll() {
cout << "Name: " << fullName;
cout << ", Age: " << ageYears;
};

private:
int ageYears;
string fullName;
};

class PetData: public AnimalData {
public:
void SetID(int petID) {
idNum = petID;
};

// FIXME: Add PrintAll() member function

/* Your solution goes here */

private:
int idNum;
};

int main() {
PetData userPet;

userPet.SetName("Fluffy");
userPet.SetAge (5);
userPet.SetID (4444);
userPet.PrintAll();
cout << endl;

return 0;
}
Computers and Technology
1 answer:
PilotLPTM [1.2K]2 years ago
8 0

Answer:

Following are the program in the C++ Programming Language.

//set header file

#include <iostream>

//set header file for string

#include <string>

//set namespace

using namespace std;

//define class

class AnimalData

{

//set access modifier

public:

//define function

void SetName(string givenName)

{

//initialize the value of function's argument

fullName = givenName;

};

//define function

void SetAge(int numYears)

{

//initialize the value of function's argument

ageYears = numYears;

};  

//here is the solution

//define function

void PrintAll()

{

//print output with message

cout << "Name: " << fullName<<endl;

//print output with message

cout << "Age: " << ageYears<<endl;

};

//set access modifier

private:

//set integer data type variable

int ageYears;

//set string data type variable

string fullName;

};

//define class and inherit the parent class

class PetData: public AnimalData

{

//set access modifier

public:

//define function

void SetID(int petID)

{

idNum = petID;

};

//override the function for print id

void PrintAll()

{

AnimalData::PrintAll();

cout << "ID: " <<idNum ;

};

//set access modifier

private:

//set integer type variables

int idNum,fullName,ageYears;

};

//define main method

int main()

{

//create object of the child class

PetData userPet;

//call function through object

userPet.SetName("Fluffy");

//call function through object

userPet.SetAge (5);

//call function through object

userPet.SetID (4444);

//call function through object

userPet.PrintAll();

cout << endl;

return 0;

}

<u>Output</u>:

Name: Fluffy

Age: 5

ID: 4444

Explanation:

<u>Following are the description of the program</u>:

  • Set required header file and namespace.
  • Define class 'AnimalData' and inside the class, set integer data type variable 'ageYears', string data type variable 'fullName'.
  1. Then, define function 'SetName()' with string data type argument 'givenName' and initialize the value of argument in the string variable.
  2. Then, define function 'SetAge()' with integer data type argument 'numYears' and initialize the value of the argument in the integer variable.
  3. Define function 'PrintAll()' to print the value of the following variables with message.
  • Define class 'PetData' and inherit the parent class in it, then set integer data type variable 'idNum'.
  1. Then, define function 'SetID()' with integer data type argument 'petID' and initialize the value of the argument in the integer variable.
  2. Override the function 'PrintAll()' to print the value of the following variable with message.

Finally, define main method and create the object of the child class, then call the following functions through the class object.

You might be interested in
HELP PLS
Umnica [9.8K]
Smart phones and wireless devices
6 0
3 years ago
Read 2 more answers
Give some examples of CyberCrime
iris [78.8K]
I think you should take a look into this link: https://www.wired.com/2009/12/ye-cybercrimes/
Here are the 10 most <span>destructive cybercrimes that you can take as areal example of cybercrime.</span>
6 0
3 years ago
If you're doing a relational comparison, which filter would be available?
taurus [48]

Answer:

C. Number

Explanation:

If you're doing a relational comparison, a number filter would be available.

7 0
3 years ago
Which option organizes tasks based on importance?
crimeas [40]

The correct answer is B. Prioritized view

Explanation:

The word "priority" is used to describe events, places, people, etc. that are considered of great importance. This means a task that is considered a priority is more important than regular tasks. In this way, in management software such as Outlook that allows users to monitor and manage tasks or things to do, users can organize tasks based on importance by clicking options such as "prioritized" or "prioritized view" that will display task from the most important to the least important. Thus, the option that organizes tasks based on importance is the prioritized view.

7 0
3 years ago
Team A found 342 errors during the software engineering process prior to release. Team B found 184 errors. What additional measu
igomit [66]

Answer:

see explaination

Explanation:

The "size" or "functionality" of the project would need to be determined. Errors/FP would provide a normalized measure.

A metric such as DRE would provide an indication of the efficiency of SQA within both teams' software process.

3 0
3 years ago
Other questions:
  • You need to put cabling for connecting two new computers in a room, which did not have any network infrastructure. Because of th
    9·2 answers
  • You can access various sites on the WWW by using hyperlinks or by
    14·1 answer
  • Which of the following should you NOT do when using CSS3 properties to create text columns for an article element? a. make the c
    12·2 answers
  • Tamara has $500 she is looking to save for a class trip. She wants to earn the most possible interest and will not need access t
    7·1 answer
  • For each entity, select the attribute that could be the unique identifier of each entity.
    12·1 answer
  • Post as a reply your example of "data, which is processed into information" case - examples should not necessarily be related to
    13·1 answer
  • Which do switches create?<br> Networks<br> Wireless access points<br> Routes<br> Collision domains
    13·1 answer
  • Match each role to the corresponding web development task.
    14·1 answer
  • Digital communication and production chapter 17
    6·1 answer
  • It is important to consider design details when creating an api because: ______________
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!