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
Write a function checkPalindrome that accepts a single argument, a string. The function should return true (Boolean) if the stri
Vsevolod [243]

Answer:

Following are the program in the Java Programming Language.

//define function

public static boolean checkPalindrome(String str){

//set integer variable to 0

int a = 0;

//set integer variable to store the length of the string

int n = str.length() - 1;  

//set the while loop to check the variable a is less than the variable n

while(a<n)

{

//check the string character is not in the variable n

if(str.charAt(a)!= str.charAt(n))

//then, return false

return false;  

//the variable a is incremented by 1

a++;

//the variable n is decremented by 1

n--;

}

//and return true

return true;

}

Explanation:

<u>Following are the description of the following function</u>.

  • Firstly, we define boolean type public function that is 'checkPalindrome' and pass string data type argument 'str' in its parameter.
  • Set two integer data type variables that are 'a' initialize to 0 and 'n' which store the length of the string variable 'str' decremented by 1.
  • Set the While loop that checks the variable 'a' is less than the variable 'n', then we set the If conditional statement to check that the string character is not in the variable n then, return false.
  • Otherwise, it returns true.
5 0
4 years ago
Which formula uses relative cell references? $A$10/100 5*10+20 F18+F19/2 $B$5+30
Mandarinka [93]

The formula that uses relative cell references is F18+F19/2.

A relative cell reference will adjust as a formula is copied because it is actually working by calculating what the formula is in relation to the cell where the formula is. For example, if you copied this formula down one row it would adjust to F19+F20/2. This is opposite of an absolute cell reference like you see in the first example. The cell will always reference cell A10, regardless of where it is copied to.

8 0
3 years ago
Write down the functions of network layer in your own words.ASAP pleaseeeeeee
Dima020 [189]

Answer:

The network layer is the layer is the layer 3 of the seven layer Open System Interconnect (OSI model) which functions as packet forwarder for the  intermediate routers  by implementing technologies used for switching that provides virtual circuits' logical path

The function of the network layer includes;

1) Routing and forwarding of packets to destination which enables connectionless communication

2) Enabling internetworking

3) Hierarchical host (IP) addressing

4) Sequencing of packets

5) Handling of errors

6) Control of network congestion to prevent the collapse of the network

Explanation:

7 0
3 years ago
Which of the following is a special-purpose computer that functions as a component in a larger product?
Dominik [7]

Answer:  

Embedded Computer

Explanation:

  • An embedded computer is designed to perform a certain function and it is a component of a larger system.
  • An embedded computer has a dedicated function within a larger system and is incorporated as a part of a complete system rather than being a stand alone computer.
  • It is a microprocessor, micro controller based real time control system.
  • Its a combination of hardware and software that have a dedicated function to achieve a specific task. The also have peripheral devices for communication purposes.  
  • Digital Camera , ATM, Calculator, Digital Watch , Self-autonomous Vehicles, Security Camera , Washing Machine , Mp3 player, Microwave Oven , Fire Alarm, Smart Phone,Vending Machines, networking hardware like dedicated routers etc are examples of embedded systems.
  • Embedded computers are less expensive to produce, consumes less power, easier to maintain, do not require remote maintenance and easily customizable.

4 0
3 years ago
A machine’s ability to mimic human thinking to behave in a way that appears to be learning and solving problems is known as:
kkurt [141]

D. game mechanics D. game mechanics

7 0
3 years ago
Other questions:
  • How do you change the username on here?
    14·1 answer
  • What purpose would tracking changes be most useful for?
    7·1 answer
  • In which of the following locations can you edit all of the Properties of a PowerPoint file?
    11·1 answer
  • All of the following are typical characteristics of internet predators, except white. male. between the ages of 18 and 35. high
    7·1 answer
  • If you want to insert a table which ribbon should you select
    13·2 answers
  • Selling R frog for 50 r-obux on r-oblox!!! dont answer if u not gonna buy it
    15·2 answers
  • How many permutations for a 7 characters in length string, which contains all following letters R, X, S, Y, T, Z, U, has either
    7·1 answer
  • It is a read mostly memory that can be electronically written into any time without arising prior contact
    12·1 answer
  • How do I answer other peoples question. is there something to click because i dont see it.
    14·2 answers
  • What number is represented as a binary code of 101110
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!