Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Did you have a Tamagotchi or Gigapet when you were young? Here's your chance to implement a very simple one. This program compiles and runs,

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Did you have a Tamagotchi or Gigapet when you were young? Here's your chance to implement a very simple one. This program compiles and runs, but does not produce the output it should, because the implementations of the member functions are incomplete or incorrect. Fix them so that the program produces the desired output. The places to make a change are denoted by TODO comments. You must make no changes whatsoever to the reportStatus, careFor, or main functions After you get everything working, try the each of the following experiments and answer the associated questions Try declaring the health member function private instead of public. Why do you get the resulting compilation error? .Comment out the entire implementation of Pet:eat, all the way from the void Pet: eat int amt) to its close curly brace. Why do you get the resulting build error? In main, replace myPets[01new Pet("Fluffy", 2); with myPets[0]new Pet("Fluffy"); or myPets[0] = new Pet, why do you get the resulting compilation errors? Try removing the const from the implementation, but not the declaration of the alive member function. What happens? Why? Try removing the const from both the declaration and the implementation of the alive member function. Explain why the use of that function doesn't compile in reportStatus, but does compile in careFor and main

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions