Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question
100%

C++ CODE HELP NEEDED

NEED MISSING CODE THAT WILL

  1. Read an integer as the number of Goat objects.
  2. Assign myGoats with an array of that many Goat objects. For each object, call object's Read() followed by the object's Print().

Ex: If the input is 2 5 87 7 71, then the output is:

Goat's age: 5

Goat's weight: 87 Goat's age: 7 Goat's weight: 71 Goat with age 7 and weight 71 is deallocated. Goat with age 5 and weight 87 is deallocated.

#include <iostream>
using namespace std;

class Goat {
public:
Goat();
void Read();
void Print();
~Goat();
private:
int age;
int weight;
};
Goat::Goat() {
age = 0;
weight = 0;
}
void Goat::Read() {
cin >> age;
cin >> weight;
}
void Goat::Print() {
cout << "Goat's age: " << age << endl;
cout << "Goat's weight: " << weight << endl;
}
Goat::~Goat() { // Covered in section on Destructors.
cout << "Goat with age " << age << " and weight " << weight << " is deallocated." << endl;
}

int main() {
Goat* myGoats = nullptr;
int count;
int i;

/* Your code goes here */

delete[] myGoats;

return 0;
}

[画像:Jump to level 1 Read an integer as the number of Goat objects. Assign myGoats with an array of that many Goat objects. For each object, call object's Read() followed by the object's Print(). Ex: If the input is 2 5 87 7 71, then the output is: Goat's age: 5 Goat's weight: 87 Goat's age: 7 Goat's weight: 71 Goat with age 7 and weight 71 is deallocated. Goat with age 5 and weight 87 is deallocated. 5 24 25 26 27 28 29123435357 38 39 40 23 25} 26 Goat::~Goat() { // Covered in section on Destructors. cout << "Goat with age " << age << " and weight " << weight << " is deallocated." << endl; 28} cout << "Goat's age: << age << endl; cout << "Goat's weight: "<< weight << endl; 30 int main() { 36 40 Goat myGoats = nullptr; int count; int i; /* Your code goes here */ delete[] myGoats; return 0;]
expand button
Transcribed Image Text:Jump to level 1 Read an integer as the number of Goat objects. Assign myGoats with an array of that many Goat objects. For each object, call object's Read() followed by the object's Print(). Ex: If the input is 2 5 87 7 71, then the output is: Goat's age: 5 Goat's weight: 87 Goat's age: 7 Goat's weight: 71 Goat with age 7 and weight 71 is deallocated. Goat with age 5 and weight 87 is deallocated. 5 24 25 26 27 28 29123435357 38 39 40 23 25} 26 Goat::~Goat() { // Covered in section on Destructors. cout << "Goat with age " << age << " and weight " << weight << " is deallocated." << endl; 28} cout << "Goat's age: << age << endl; cout << "Goat's weight: "<< weight << endl; 30 int main() { 36 40 Goat myGoats = nullptr; int count; int i; /* Your code goes here */ delete[] myGoats; return 0;
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education