C++ CODE HELP NEEDED NEED  MISSING CODE THAT WILL  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.   #include 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;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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;
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education