The given code for my program is:
class Hive
{
private:
Bee* queen;
Bee* worker;
Bee* drone;
public:
Hive();
void activity();
~Hive();
};
Coding instructions have been provided and I must add the code. My constructor as coded, has the following error:"Cannot allocate an object of abstract type"
Hive::Hive() //This is where my error is
{
//Create an instance of each derived class
queen = new Queen(1,1) ;
worker = new Worker(1,1) ;
drone = new Drone(1,1) ;
}
void Hive::activity()
{
//Polymorphically call each classes work function
queen->Work() ;
worker->Work() ;
drone->Work() ;
}
Hive::~Hive()
{
//Deal with dynamic memory
delete queen ;
delete worker ;
delete drone ;
}
My derived class definitions are:
class Drone : Bee /*Indicate that a Drone IS A Bee*/
{
private:
char fertile;
public:
Drone(int lifespan, char fertile);
virtual void work();
};
class Queen : Bee /*indicate that a Queen IS A Bee*/
{
private:
int numBabies;
public:
Queen(int lifespan, int numBabies);
virtual void work();
};
class Worker : Bee /*Indicate that a Worker IS A Bee*/
{
private:
int honeyMade;
public:
Worker(int lifespan, int honeyMade);
virtual void work();
};
Hopefully I didn't make additional mistakes.
The main:
Classes
///
///
/////
///
///
///
////
///