Download the file Insect.cpp(mentioned below) and use this as your start file. Inside the file you will see the implementation of the class Insect. Do the following: a. Write a class BumbleBee that inherits from Insect. Add the public member function void sting() const . This function simply prints "sting!" and a newline. b. Write a class GrassHopper that inherits from Insect. Add the public member function void hop() const . This function simply prints "hop!" and a newline. When you are done your program output should look exactly like the output provided at the end of the file. insect.cpp   #include using namespace std; // Insect class declaration class Insect {    protected:        int antennae;        int legs;        int eyes;           public:               // default constructor        Insect();                     // getters        int getAntennae() const;        int getLegs() const;        int getEyes() const;       }; // BumbleBee class declaration // GrassHopper class declaration // main int main() { BumbleBee bumble; GrassHopper hopper;    cout << "A bumble bee has " << bumble.getLegs() << " legs and can ";    bumble.sting();    cout << endl;    cout << "A grass hopper has "        << hopper.getLegs() << " legs and can ";    hopper.hop();    return 0;    } // member function definitions Insect::Insect() {    antennae = 2;    eyes = 2;    legs = 6; } int Insect::getAntennae() const { return antennae; } int Insect::getLegs() const { return legs; } int Insect::getEyes() const { return eyes; } /* A bumble bee has 6 legs and can sting! A grass hopper has 6 legs and can hop! */ Do not modify the main program. Do not modify the Insect class.

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

Download the file Insect.cpp(mentioned below) and use this as your start file. Inside the file you will see the implementation of the class Insect. Do the following:

a. Write a class BumbleBee that inherits from Insect. Add the public member function void sting() const . This function simply prints "sting!" and a newline.

b. Write a class GrassHopper that inherits from Insect. Add the public member function void hop() const . This function simply prints "hop!" and a newline.

When you are done your program output should look exactly like the output provided at the end of the file.

insect.cpp

 

#include <iostream>
using namespace std;

// Insect class declaration
class Insect
{
   protected:
       int antennae;
       int legs;
       int eyes;
      
   public:
      
       // default constructor
       Insect();      
      
       // getters
       int getAntennae() const;
       int getLegs() const;
       int getEyes() const;      
};

// BumbleBee class declaration


// GrassHopper class declaration


// main
int main()
{
BumbleBee bumble;
GrassHopper hopper;
  
cout << "A bumble bee has " << bumble.getLegs() << " legs and can ";
   bumble.sting();
  
cout << endl;
  
cout << "A grass hopper has "
       << hopper.getLegs() << " legs and can ";
   hopper.hop();
  
return 0;   
}

// member function definitions
Insect::Insect()
{
   antennae = 2;
   eyes = 2;
   legs = 6;
}
int Insect::getAntennae() const
{ return antennae; }
int Insect::getLegs() const
{ return legs; }
int Insect::getEyes() const
{ return eyes; }

/*
A bumble bee has 6 legs and can sting!

A grass hopper has 6 legs and can hop!

*/

Do not modify the main program. Do not modify the Insect class.

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
Reference Types in Function
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
  • SEE MORE 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