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]
3 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]3 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
Draw a flowchart to convert 5 kg into gram .​
dlinn [17]

Answer:

Kg to g, multiply by 1000

Therefore, 5 Kg = 5000 gms

Explanation:

5 0
3 years ago
Read 2 more answers
If your presentation uses a background, your text should _____.
Klio2033 [76]

your text should work well with the background.

It's very important for the text to be readable.

5 0
3 years ago
Read 2 more answers
A time line may identify cause or effect of an event?<br> True or False?
levacccp [35]
True whenever you look at one it helps identify the cause/effect of an event
3 0
3 years ago
Keystroke loggers are stealth software packages that are used to monitor keyboard activities. Which is the best location to plac
irina [24]

Answer: Keyboard hardware & the operating system

Explanation:Keystroke loggers is also referred as the monitoring system which is a for the inspection of the every key pressed on an operating system. This technology monitors the activities of keypad devices such as smart phones etc. It is also used for the surveillance of the unauthorized activities that are done by the hackers or criminals.

Thus the correct option is keyboard hardware and the operating system is the location of the placement of the key loggers.

7 0
4 years ago
To remedy the lack of procedural functionality in SQL, and to provide some standardization within the many vendor offerings, the
MrRa [10]

Answer:

The correct answer is True.

Explanation:

The SQL: 1999 standard calls a Boolean type, but many commercial SQL servers (Oracle Database, IBM DB2) do not support it as a valid column type, a variable type or to allow it in the result set. Microsoft SQL Server is one of the few database systems that correctly supports Boolean type values using its "BIT" data type. Each 8 BIT fields occupy a full byte of disk space. MySQL interprets "BOOLEAN" as a synonym for TINYINT (8-bit signed integer). PostgreSQL provides a Boolean type of standard compliance.

5 0
3 years ago
Other questions:
  • In order to accomplish the same goal, a person can click and hold down the mouse button and drag to the right, or hold Shift and
    10·1 answer
  • Risa has a negative credit rating, and she feels obtaining a fresh loan credit is going to be quite difficult for her. Her frien
    15·1 answer
  • Recall that through either photographic or computer technology, researchers can make a composite (or "averaged") face out of any
    11·1 answer
  • Amy, a project manager, needs to make a plan that ensures consistent delivery of the right message to the right people at the ri
    11·1 answer
  • Write a function named wordLineCount with the following input and output: Input: a string parameter, inFile, that is the name of
    9·1 answer
  • What is the purpose of the operating system's processor management function?
    14·1 answer
  • Viruses and worms can affect a system by:
    11·2 answers
  • Can't get Brainly to load on my Apple Mac. Why won’t it load? Does it need another program to work?
    14·2 answers
  • What is the collection of programs designed to operate control and manage the actual operation of the computer equipment​
    14·1 answer
  • QUESTION 7
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!