I keep getting this error message and I cant figure out how to fix it. Im not sure whether I have been trying to fix it for to long or somehting that maybe im not seeing the problem:

ItemType::ItemType' : error in function definition or declaration; function not called

it says the same thing for my PromoteMe,DemoteMe,EPrint,UPrint functions when i try to use them in my EmpType.ccp.

Any help would be great thanks
//ItemType.h

#include <string>
#include <iostream>
#include <fstream>

const int MAX_ITEMS = 5;
using namespace std;
enum RelationType {LESS, EQUAL, GREATER} const;
class ItemType
{
      public:
			//constructor
		   ItemType(string myName,string myCompany);
		   
		   RelationType ComparedTo(ItemType)const;
		   //Purpose: compares objects
		   //Precondition: self and item have their key members initalized
		   //Postcondition:= LESS if the key of self is less then the key of item
						 //= GREATER if the key of self is greater then the key of item
						 //= EQUAL if the keys are equal
           void PromoteMe();           
				//Function: promotes the employee
				//Postcondition: Employee is promoted
		   void DemoteMe();
				//Function: demotes the employee
				//Postcondition: Employee is promoted
		   void PayMe(bool okay);
				//Postcondition: pays the employees
		   void EPrint();
		   void UPrint();

      private:
			  ofstream outData;
			  string company;
              string name;
              int rank;
              int total;
};

//constructor
ItemType :: ItemType(string myName, string myCompany)
{
        name = myName;
        company = myCompany;
        rank = 1;
        total = 0;
}

RelationType ItemType::ComparedTo(ItemType otherObj) const
{
        if((company < otherObj.company)||(company == otherObj.company)
        &&(rank < otherObj.rank))
              return LESS;
        else if((company > otherObj.company)||(company == otherObj.company)
        && (rank > otherObj.rank))
              return GREATER;
        else
              return EQUAL;
}

void ItemType::PromoteMe()
{
     
    rank = rank+1;
}

void ItemType::DemoteMe()
{
	rank = rank-1;
}

void ItemType::PayMe(bool okay);
{
	if(!okay)
	total = total + rank * 1000;
	else
		total = total+ 50;
}

void ItemType::EPrint()
{
		cout<<"Name: "
			<<name<<endl;
		outData<<"Name: "
			<<name<<endl;
		cout<<"Company: "
			<<company<<endl;
		outData<<"Compnay: "
			<<company<<endl;
		cout<<"Rank: "
			<<rank<<endl;
		outData<<"Rank: "
			<<rank<<endl;
		cout<<"Total Pay: "
			<<total<<endl;
		outData<<"Total Pay: "
			   <<total<<endl;
		cout<<endl;
		outData<<endl;
}

void ItemType::UPrint()
{

		cout<<"Name: "
			<<name<<endl;
		outData<<"Name: "
			<<name<<endl;
		cout<<"Total Pay: "
			<<total<<endl;
		outData<<"Total Pay: "
			<<total<<endl;
}

//EmpType.ccp

#include <iostream>
#include <fstream>
#include <string.h>
#include "SortedType.h"
#include "ItemType.h"


ofstream outData;
enum CommandType {JOIN,QUIT,CHANGE,PROMOTE,DEMOTE,
PAYDAY,EMPLOYEES,UNEMPLOYED,DUMP,END};
void Join(SortedType&);
void GetCommand(CommandType&);
void Quit(SortedType&,SortedType&);
void Change(SortedType&);
void Unemployed(SortedType&);
void Dump(SortedType&,SortedType&);
void Employees(SortedType&);
void Payday(SortedType&,SortedType&);
void Demote(SortedType&);
void Promote(SortedType&);

void main()
{
    using namespace std;
	cout<<"Welcome to the Employee Program"<<endl;
	CommandType command;
	SortedType ourList,list2;
    
    outData.open("data.dat");
	GetCommand(command);
	while(command != END)
	{
		switch(command)
		{
			case JOIN: Join(ourList);break;
			case QUIT: Quit(ourList,list2);break;
			case CHANGE: Change(ourList);break;
			case PROMOTE: Promote(ourList);break;
			case DEMOTE: Demote(ourList);break;
			case PAYDAY: Payday(ourList,list2);break;
			case EMPLOYEES: Employees(ourList);break;
			case UNEMPLOYED: Unemployed(list2);break;
			case DUMP: Dump(ourList,list2);break;
		}
		GetCommand(command);
	}

}

void GetCommand(CommandType& command)
{
    
	cout<<"EMPLOYEE MENU PROGRAM"<<endl;
	outData<<"EMPLOYEE MENU PROGRAM"<<endl;
	cout<<"Type in a Capitial letter from the choices below then press ENTER"<<endl;
	outData<<"Type in a Capitial letter from the choices below then press ENTER"<<endl;
	cout<<endl;
	outData<<endl;
	cout<<" J: A person joins a new company."<<endl;
	outData<<" J: A person joins a new company."<<endl;
	cout<<" Q: A person quits a company."<<endl;
	outData<<" Q: A person quits a company."<<endl;
	cout<<" C: A person quits their job and joins a different company."<<endl;
	outData<<" C: A person quits their job and joins a different company."<<endl;
	cout<<" P: A person is promoted."<<endl;
	outData<<" P: A person is promoted."<<endl;
	cout<<" D: A person is demoted."<<endl;
	outData<<" D: A person is demoted."<<endl;
	cout<<" M: payday."<<endl;
	outData<<" M: payday."<<endl;
	cout<<" E: Print list of employees in a company."<<endl;
	outData<<" E: Print list of employees in a company."<<endl;
	cout<<" U: Print list of unemployeed people."<<endl;
	outData<<" U: Print list of unemployeed people."<<endl;
	cout<<" A: Print both employee and unemployeed list."<<endl;
	outData<<" A: Print both employee and unemployeed list."<<endl;
	cout<<" X: END OF PROGRAM"<<endl;
	outData<<" X: END OF PROGRAM"<<endl;
	char letter;
	cin>>letter;
	cout<<endl;

	bool okay = false;
	while(!okay)
	{
		okay = true;
		switch(letter)
		{
		
			case 'J': command = JOIN; break;
			case 'Q': command = QUIT; break;
			case 'C': command = CHANGE; break;
			case 'P': command = PROMOTE;break;
			case 'D': command = DEMOTE;break;
			case 'M': command = PAYDAY; break;
			case 'E': command = EMPLOYEES; break;
			case 'U': command = UNEMPLOYED; break;
			case 'A': command = DUMP;break;
			case 'X': command = END;break;
			default: cout<<"Letter Entered was not one"
						 <<" of the choices above. ENTER"
						 <<" another Letter then press return: "<<endl;
					 outData<<"Letter Entered was not one"
						 <<" of the choices above. ENTER"
						 <<" another Letter then press return: "<<endl;
				     cin>>letter;
					 okay = false;
		}
	}
}

void Join(SortedType& ourList,SortedType& list2)
{
     bool check = false;
     string name,company;
     cout<<"Enter the employee's name"<<endl;
	 outData<<"Enter the employee's name"<<endl;
     cin>>name;
     cout<<"Enter the company"<<endl;
	 outData<<"Enter the company"<<endl;
     cin >> company;
     
     ItemType obj(name,company);
     int length = ourList.LengthIs();

	 if(list2.RetrieveItem(obj,check))
		 list2.DeleteItem(obj);
     
     for(int count = 0;count < length;count++)
     {
          ourList.GetNextItem(obj);
          ourList.DeleteItem(obj);
          obj.PromoteMe();
          ourList.InsertItem(obj);
     }
     
     ourList.InsertItem(obj);
     ourList.ResetList();
}

void Quit(SortedType& list2,SortedType& ourList)
{
     
	 cout<<"QUIT"<<endl;
     string name,company;
     cout<<"Enter the employee's name"<<endl;
	 outData<<"Enter the employee's name"<<endl;
     cin>>name;
     cout<<"Enter the company"<<endl;
	 outData<<"Enter the company"<<endl;
     cin >> company;
	
	 ItemType obj(name,company);
	 int length = ourList.LengthIs();
	 ourList.DeleteItem(obj);
	 list2.InsertItem(obj);
	
	 
	 for(int count = 0;count < length;count++)
     {
          ourList.GetNextItem(obj);
          obj.DemoteMe();
          ourList.InsertItem(obj);
     }
}

void Change(SortedType& ourList)
{
     cout<<"CHANGE"<<endl;
	 bool check = false;
	 string name,company;
	 while(!check)
	 {
		check = true;
		
		cout<<"Enter the employee's name"<<endl;
		outData<<"Enter the employee's name"<<endl;
		cin>>name;
		cout<<"Enter the company"<<endl;
		outData<<"Enter the company"<<endl;
		cin >> company;
     
		ItemType obj(name,company);
		int length = ourList.LengthIs();

		ourList.DeleteItem(obj);

		for(int count = 0;count < length;count++)
		{
          ourList.GetNextItem(obj);
          obj.PromoteMe();
          ourList.InsertItem(obj);
		}
		ourList.ResetList();
     }
	
	 int length = ourList.LengthIs();
	 ItemType obj(name,company);
     for(int count = 0;count < length;count++)
     {
          ourList.GetNextItem(obj);
          ourList.DeleteItem(obj);
          obj.PromoteMe();
          ourList.InsertItem(obj);
     }
     
     ourList.InsertItem(obj);
     ourList.ResetList();
}

void Promote(SortedType& ourList)
{
    string name,company;
	cout<<"PROMOTE"<<endl;
	cout<<"Enter the employee's name"<<endl;
	outData<<"Enter the employee's name"<<endl;
	cin>>name;
	cout<<"Enter the company"<<endl;
	outData<<"Enter the company"<<endl;
	cin >> company;
	
	ItemType obj(name,company);
	ItemType obj2(name,company);
	int length = ourList.LengthIs();
		
	if(obj.rank < length)
	{
		ourList.DeleteItem(obj);
		ourList.GetNextItem(obj2);
		ourList.DeleteItem(obj2);
		ourList.InsertItem(obj2);
		ourList.InsertItem(obj);
		obj.PromoteMe();
		obj2.DemoteMe();
	}
	else
	{
		cout<<"The person is already in the top position"
			<<"They can not be promoted"<<endl;
		outData<<"The person is already in the top position"
			<<"They can not be promoted"<<endl;
	}
}

void Demote(SortedType& ourList)
{
    string name,company;
	cout<<"DEMOTE"<<endl;
	cout<<"Enter the employee's name"<<endl;
	outData<<"Enter the employee's name"<<endl;
	cin>>name;
	cout<<"Enter the company"<<endl;
	outData<<"Enter the company"<<endl;
	cin >> company;
	
	ItemType obj(name,company);
	ItemType obj2(name,company);
	int length = ourList.LengthIs();
		
	if(obj.rank < length)
	{
		ourList.DeleteItem(obj);
		ourList.GetNextItem(obj2);
		ourList.DeleteItem(obj2);
		ourList.InsertItem(obj2);
		ourList.InsertItem(obj);
		obj.DemoteMe();
		obj2.PromoteMe();
	}
	else
	{
		cout<<"The person is already in the bottom position"
			<<"They can not be demoted"<<endl;
		outData<<"The person is already in the bottom position"
			<<"They can not be demoted"<<endl;
	}
}
		
void Payday(SortedType& ourList, SortedType& list2)
{
    
	cout<<"PAYDAY"<<endl;
	outData<<"PAYDAY"<<endl;
	string name,company;
	ItemType obj(name,company);
	bool okay = false;
	int length = ourList.LengthIs();
	ourList.ResetList();
	for(int count = 0;count < length;count++)
	{

		ourList.GetNextItem(obj);
		obj.PayMe(okay);
	}
	
	list2.ResetList();
	int size = list2.LengthIs();
	okay = true;
	for(int k = 0;k < size;k++)
	{
		list2.GetNextItem(obj);
		obj.PayMe(okay);
	}
}
	
void Employees(SortedType& ourList)
{
	string name,company;
    ItemType obj(name,company); 
	cout<<"EMPLOYEES"<<endl;
	outData<<"EMPLOYEES"<<endl;
	cout<<"Enter the company's name:"<<endl;
	outData<<"Enter the company's name:"<<endl;
	cin>>company;
	ourList.ResetList();
	int length = ourList.LengthIs();
	for(int count = 0;count < length;count++)
	{
		ourList.GetNextItem(obj);
		obj.EPrint();
	}
	ourList.ResetList();
}

void Unemployed(SortedType& list2)
{
    string name,company;
	cout<<"UNEMPLOYED"<<endl;
	ItemType obj(name,company);;
	int length = list2.LengthIs();
	list2.ResetList();
	for(int count = 0;count < length;count++)
	{	
		list2.GetNextItem(obj);
		obj.UPrint();
	}
	list2.ResetList();
}

void Dump(SortedType& list2, SortedType& ourList)
{
	string name,company;
    ItemType obj(name,company);
	cout<<"DUMP"<<endl;
	int length = ourList.LengthIs();
	cout<<"EMPLOYEES"<<endl;
	for(int count = 0;count < length;count++)
	{	
		ourList.GetNextItem(obj);
		obj.EPrint();
	}
	
	int length2 = list2.LengthIs();
	cout<<"UNEMPLOYED"<<endl;
	for(int k = 0;k < length2;k++)
	{	
		list2.GetNextItem(obj);
		obj.UPrint();
		
	}
}

Recommended Answers

All 3 Replies

One of these characters doesn't belong. Can you find it?

void ItemType::PayMe(bool okay);
{
  if(!okay)
    total = total + rank * 1000;
  else
    total = total+ 50;
}

Sadly, I don't have your other header, and I'm too lazy to go through all the code you posted. So why don't you hack and slash your code so that it's smaller and doesn't rely on mystery headers and post it again.

I dont understand what u exactly want me to do but here is the other header:
Thanks

#include "ItemType.h" 
// File ItemType.h must be provided by the user of this class. 
//  ItemType.h must contain the following definitions: 
//  MAX_ITEMS:     the maximum number of items on the list 
//  ItemType:      the definition of the objects on the list 
//  RelationType:  {LESS, GREATER, EQUAL}
//  Member function ComparedTo(ItemType item) which returns 
//       LESS, if self "comes before" item 
//       GREATER, if self "comes after" item 
//       EQUAL, if self and item are the same 

class SortedType 
{
public:
  SortedType();
  bool IsFull() const;
  int LengthIs() const;
  void RetrieveItem(ItemType& item, bool& found);
  void InsertItem(ItemType item);
  void DeleteItem(ItemType item);
  void ResetList();
   void GetNextItem(ItemType& item);
  

private:
  int length;
  ItemType info[MAX_ITEMS];
  int currentPos;
};

>I dont understand what u exactly want me to do
Make less code with same problem. How hard is that?

>but here is the other header
You're including ItemType.h twice. That's a big no-no if your headers have definitions. Do this:

#ifndef ITEMTYPE
#define ITEMTYPE

// Contents of ItemType.h here

#endif

That's a Band-Aid to get you to the real problems. Have fun.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.