Question
The code below has five errors. The errors may be syntax errors, logic errors, or cause a memory leak. Examine the code carefully to find
The code below has five errors. The errors may be syntax errors, logic errors, or cause a memory leak. Examine the code carefully to find them. Indicate each of the errors you find by writing the line number and correction in the space provided below. If there were no errors, this code would output the following with no memory leaks: A dog named Barkly is here. Barkly barks here. A gray cat named Ms. Kitty is here. Ms. Kitty meows gently. You must find and correct all five of the errors. 1 #include 2 #include #include using namespace std; class Animal public: 7 Animal (string name, double weight) {m_name = name; m_weight = weight;} virtual string GetName() = 0; 9 virtual double GetWeight() = 0; 10 void Speak () { cout myAnimals; 35 Animal* myAnimal; 36 myAnimal = new Dog (\"Barkly\", 21.5); 37 myAnimals.push_back (myAnimal); 38 myAnimal = new Cat (\"Ms. Kitty\", \"gray\", 10.75); 39 myAnimals.push_back (myAnimal); 40 for (int i = 0; i GetName() Speak(); 43 delete myAnimals.at(i); 44 } 45 return 0; 46 } 47
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started