Why am I getting this error c:\documents and settings\andrew\desktop\important stuff\acs 279\program1\new folder\queue.h(3) : error C2011: 'IntQueue' : 'class' type redefinition in this code?
Code:
//////////////////////////////////////////////////////////////////////
//Andrew Jackson Queue.h file //
//////////////////////////////////////////////////////////////////////
struct NodeType;
class IntQueue {
public:
IntQueue();
IntQueue(const IntQueue& otherQ);
void Enqueue(int newItem);
int Front() const;
void Dequeue();
~IntQueue();
private:
NodeType* front;
NodeType* rear;
};
Implementation file
#include"Queue.h"
#include<stddef.h>
#include<alloc.h>
typedef NodeType* NodePtr;
struct NodeType
{
int data;
NodePtr link;
};
////////////////////////////////////////////////////////////////////
void CopyList(NodePtr, NodePtr&, NodePtr&);
IntQueue::IntQueue()
{
front = rear = NULL;
}
////////////////////////////////////////////////////////////////////
IntQueue::~IntQueue()
{
NodePtr tempPtr;
while(front != NULL)
{
tempPtr = front;
front = tempPtr->link;
delete tempPtr;
}
}
/////////////////////////////////////////////////////////////////////
IntQueue::IntQueue(const IntQueue& otherQ)
{
if(otherQ.front == NULL)
front = rear = NULL;
else
CopyList(otherQ.front, front, rear);
}
//////////////////////////////////////////////////////////////////////
void IntQueue::Enqueue(int newItem)
{
NodePtr newPtr = new NodeType;
newPtr->data = newItem;
newPtr->link = NULL;
if(front == NULL)
front = rear = newPtr;
else{
rear->link = newPtr;
rear = newPtr;
}
}
//////////////////////////////////////////////////////////////////////
int IntQueue::Front() const
{
return front->data;
}
//////////////////////////////////////////////////////////////////////
void IntQueue::Dequeue()
{
NodePtr tempPtr = front;
front = tempPtr->link;
delete tempPtr;
if(front == NULL)
rear = NULL;
}
//////////////////////////////////////////////////////////////////////
void CopyList(NodePtr currPtr, NodePtr& cloneFront, NodePtr& cloneRear)
{
NodePtr newPtr = NULL; {
CopyList(currPtr->link, cloneFront, cloneRear);
newPtr = new NodeType;
newPtr->data = currPtr->data;
newPtr->link = cloneFront;
if(currPtr->link == NULL)
cloneRear = newPtr;
}
cloneFront = newPtr;
}
//******************************************************************//
//Program Queue client file //
// //
// //
// //
// //
// //
// //
//******************************************************************//
#include<iostream>
#include<iomanip>
#include<fstream>
#include <cstdlib>
#include"Queue.h"
#include"QueueImpl.cpp"
using namespace std;
int CalculateTime(int service);
int main()
{
IntQueue Queue;
/*
ifstream Infile;
ofstream Outfile;
Infile.open("inputQ.txt");
Outfile.open("OUTPUTQ.TXT");
int y = rand();
int x = rand();
int minutes = 720;
int Seed, arrive, service;
int customer = 0;
int CustomerNumber=0;
int runningtime;
int time=0;
srand(Seed);
y = rand();
x = rand();
Infile>>customer;
while(customer < 5)
{
srand(customer);
arrive = rand()%100; //First cutsomer arrival time
service = rand()%100; //First customer service time
CustomerNumber++;
Outfile<<"Customer "<<CustomerNumber<<endl;
Outfile<<"Customer "<<CustomerNumber<<" arrival time "<<arrive<<endl;
Outfile<<"Customer "<<CustomerNumber<<" service time "<<service<<endl;
time = CalculateTime(service);
Outfile<<time;
Infile>>customer;
}
/*srand((unsigned)time(NULL)); //Casts time's return to unsigned
int d=rand()%12; //Should be more random now
Outfile<<d;
*/
return 0;
}
/*
int CalculateTime(int service)
{
int minutes= 720;
int time;
{
while(minutes > 0)
service++;
minutes--;
}
time = service;
return time;
}