A Simple Employee Database in C++

This is just part of a group of classes used to create an employee database. The employeegroup class uses pointers which are used for memory management (as opposed to Java which does the memory management for you.) If for some reason you'd like the entire program, let me know and I'll send you a copy containing all the classes used. Just post a comment to leave me a message.
#include "employeegroup.h"
 
EmployeeGroup::EmployeeGroup() : EGname("BLANK"), head(NULL), tail(NULL), lastreturn(NULL), exists_head(false), exists_tail(false), size(0) 
{}
 
EmployeeGroup::EmployeeGroup(String s)
{
	EGname=s;
	head=NULL;
	tail=NULL;
	lastreturn=NULL;
	exists_head=false;
	exists_tail=false;
	size=0;
}
 
EmployeeGroup::~EmployeeGroup()
{
	enode* current = head;
	while(current!=NULL)
	{
		enode* next=current->next;
		delete current;     
		current = next;
	}
}
 
void EmployeeGroup::name(String n)
{
	EGname=n;
}
 
String EmployeeGroup::name()
{
	return EGname;
}
bool EmployeeGroup::insert(Employee e)
{
     enode *q,*t;
 
		 // Condition where neither head nor tail exists
		 if(head==NULL)
		 {
			cout << "Inserting head (first node)..." << endl;
			enode* temp = new enode;
			temp->e = e;
			temp->next = NULL;
			head=temp;
			exists_head=true;
			size++;
			return (true);
		 }
		 if (employee_already_exists(e))
			 return (false);
		 // Condition where head exists but no tail exists
		 t=head;
		 if (exists_head==true)
			 if(exists_tail==false)
			 {
 
				  if (t->e.idno < e.idno)   //insertion after head
				  {
					  enode* temp = new enode;
					  temp->e = e;
					  temp->next = NULL;
					  t->next = temp;
					  tail=temp;
					  size++;
					  exists_tail=true;
					  cout << "Inserting after head successful!" << endl;
					  return (true);
				  } else   //insertion before head
				  {
					  enode* temp = new enode;
					  temp->e = e;
					  temp->next = head;
					  tail = head;
					  head = temp;
					  size++;
					  exists_tail=true;
					  cout << "Inserting before head successful!" << endl;
					  return (true);
				  }
			 }
 
			 // Condition where head exists and tail exists
			 q=head;
			 if (exists_head)
				if(exists_tail)
				{
					if (e.idno < q->e.idno)
					{
						  enode* temp = new enode;
						  temp->e = e;
						  temp->next = head;
						  head = temp;
						  size++;
						  cout << "Inserting before head successful!" << endl;
						  return (true);
 
					}
					if (e.idno > tail->e.idno)
					{
						  enode* p;
						  p=tail;
						  enode* temp = new enode;
						  temp->e = e;
						  temp->next = NULL;
						  p->next = temp;
						  tail=temp;
						  size++;
						  cout << "Inserting after tail successful!" << endl;
						  return (true);				
					}
					//If above two conditions are not met, we insert in the middle
					q=head;
				    while(q->next != NULL)
					{
					if ( q->e.idno < e.idno ) 
						if ( q->next->e.idno > e.idno )
						{
							enode* temp = new enode;
							temp->e = e;
							temp->next = q->next;
						    q->next = temp;
			                cout << "Inserting in the middle..." << endl;
			                size++;
			                return (true);
						}
			          q = q->next;
					}
				}
				return(false);
}
 
bool EmployeeGroup::employee_already_exists (Employee e)
{
	  enode* current;
	  current = head;
	  if (current->next==NULL)
	  {
	   	 if (current->e == e)
			{
				//cout << "An employee with that ID already exists.";
				return (true);
			}
	  }
	  while(current->next != NULL)		//Loop to see if an employee with an equal ID exists
	  {		
 
			if (current->e == e)
				{
					//cout << "An employee with that ID already exists.";
					return (true);
				}
			current = current->next;
	  }	
	return (false);
}
 
 
void EmployeeGroup::display()
{
cout << "\nEmployee group name is " << EGname << endl;
enode* current=head;
cout << "The pointer for head is " << head << endl;
while (current != NULL)
	{
		current->e.write();
		cout << "The next pointer for this person is " << current->next << endl;
		current = current->next;
	}
 
}
 
Employee EmployeeGroup::get_next()
{
	if (lastreturn==NULL)
	{
		lastreturn=head;
		lastreturn->e.write();
		return (lastreturn->e);
	}
	else
	{
		if (lastreturn->next==NULL)
		{
			cout << "End of List" << endl;
			return (NULL_EMP);
		} else
		{
		enode* temp;
		temp=lastreturn;
		lastreturn=lastreturn->next;
		temp->next->e.write();
		return (temp->next->e);
		}
	}
}
 
bool EmployeeGroup::remove( int id )
{
     enode *q,*r;
     q = head;
     if( q->e.idno == id )
		{
			head = q->next;
			delete q;
			size--;
			return (true);
		}
 
      r = q;
      while( q!=NULL )
      {
        if( q->e.idno == id )
             {
				r->next = q->next;
				delete q;
				size--;
				return (true);
			 }
 
      r = q;
      q = q->next;
   }
   cout<<"\nElement "<<id<<" not Found.";
   return (false);
}
 
 
int EmployeeGroup::empcount()
{
	return size;
}
 
Employee EmployeeGroup::find(int id)
{
	if (exists_head==false)				//Check to see if there's a head. If not, break.
	{
		cout << "There are no employees in this group.\n" << endl;
		return NULL_EMP;
	}
	enode* current=head;
	while (current->e.idno!=id)
	{
 
		if (current->next==NULL)
		{
			cout << "No employee with id "<< id << " was found.\n" << endl;
			return NULL_EMP;
		}
		else
		{
			current=current->next;
		}
	}
	cout << "We found the employee!!!" << endl;
	return (current->e);
 
}
Posted in C++