Click here to Skip to main content
15,895,953 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hive.cpp
C++
#include "Hive.h"
#include <iostream>

using namespace std;

namespace HiveSpace
{
	Hive::Hive()
	{
		what to write here? //Create an instance of each derived class
	}
	
	void Hive::activity()
	{
		???? //Polymorphically call each classes work function
	}
	
	Hive::~Hive()
	{
		????? //Deal with dynamic memory
	}
}

hive.h
C++
#ifndef HIVE_H
#define HIVE_H

#include "Bee.h"
#include "Queen.h"
#include "Drone.h"
#include "Worker.h"

namespace HiveSpace
{
	class Hive
	{
		private:
			Bee* queen;
			Bee* worker;
			Bee* drone;
		
		public:
			Hive();
			void activity();
			~Hive();
	};
}

#endif
Posted
Updated 19-Aug-15 0:08am
v3
Comments
Ujesh Mohanan 19-Aug-15 14:41pm    
If you don't know how to complete it, then how can you expect some one else to complete it?

1 solution

your ctor needs to create the members, the dtor needs to delete them and activity() needs to call whatever virtual they all share

you should maybe read the course notes again, or talk to your tutor/lecturer
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900