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
Which character goes at the end of a line of code that starts with if?
weqwewe [10]

Answer:

Explanation:

tttttttttttt

4 0
3 years ago
Read integers from input and store each integer into a vector until -1 is read. Do not store -1 into the vector. Then, output al
weqwewe [10]

Answer:

The program in C++ is as follows:

#include <iostream>

#include <vector>

using namespace std;

int main(){

vector<int> nums;

int num;

cin>>num;

while(num != -1){

 nums.push_back(num);

 cin>>num; }  

for (auto i = nums.begin(); i != nums.end(); ++i){

    cout << *i <<endl; }

return 0;

}

Explanation:

This declares the vector

vector<int> nums;

This declares an integer variable for each input

int num;

This gets the first input

cin>>num;

This loop is repeated until user enters -1

while(num != -1){

Saves user input into the vector

 nums.push_back(num);

Get another input from the user

 cin>>num; }

The following iteration print the vector elements

<em> for (auto i = nums.begin(); i != nums.end(); ++i){ </em>

<em>     cout << *i <<endl; } </em>

6 0
2 years ago
A website wants to gives out detailed information to viewers about its upcoming conference and also provides a feature for searc
Alenkinab [10]

Answer: WIREFRAME

A website wireframe, also known as a page schematic or screen blueprint, is a visual guide that represents the skeletal framework of a website.[1]:166 Wireframes are created for the purpose of arranging elements to best accomplish a particular purpose. The purpose is usually being informed by a business objective and a creative idea. The wireframe depicts the page layout or arrangement of the website's content, including interface elements and navigational systems, and how they work together.[2]:131 The wireframe usually lacks typographic style, color, or graphics, since the main focus lies in functionality, behavior, and priority of content.[1]:167 In other words, it focuses on what a screen does, not what it looks like.[1]:168 Wireframes can be pencil drawings or sketches on a whiteboard, or they can be produced by means of a broad array of free or commercial software applications. Wireframes are generally created by business analysts, user experience designers, developers, visual designers, and by those with expertise in interaction design, information architecture and user research.

3 0
3 years ago
3. When code tracing, why is it important to iteratively test parts of the program?
GenaCL600 [577]

Answer:

A. To isolate errors in the outcomes of code.

<em>Hope this helps! ^-^</em>

<em>-Isa</em>

7 0
3 years ago
"the ____ criteria filter requires the records displayed to have the specified text string anywhere."
Debora [2.8K]

The contains criteria filter requires the records displayed to have the specified text string anywhere. Thecontains operator is used to perform case-sensitive matching regardless of location in strings.

The begins with criteria filter on the other hand requires the records displayed to start with the specified text string

3 0
2 years ago
Other questions:
  • Drag the correct type of update to its definition.
    5·1 answer
  • It is a good idea to use more than one typeface in a document when _____.
    8·2 answers
  • This type of method method performs a task and sends a value back to the code that called it:
    5·1 answer
  • Pls help me
    5·1 answer
  • A form letter can be customized by using different fields in a __________.
    15·2 answers
  • Type the correct answer in the box. Spell all words correctly.
    13·1 answer
  • create a function that draws a certain number of spaces, followed by a certain number of stars, followed by a newline.
    6·1 answer
  • Who is the father of computer?​
    14·1 answer
  • What kind of AR target category makes sense for a playing card with a picture on it?
    12·1 answer
  • What does a companys code of ethics cover
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!