how to find error of my coding?

this is my code of McD simulation
but i can't find the error..
if can, i don't want the header file because its difficult for me to find the error..
1 C:\Dev-Cpp\include\c++\3.4.2\backward\iostream.h:31, from C:\Documents and Settings\Administrator\My Documents\datastructured\main.cpp In file included from C:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31, from C:\Documents and Settings\Administrator\My Documents\datastructured\main.cpp
1 C:\Documents and Settings\Administrator\My Documents\datastructured\main.cpp from C:\Documents and Settings\Administrator\My Documents\datastructured\main.cpp
14 C:\Documents and Settings\Administrator\My Documents\datastructured\main.cpp `queue' has not been declared
14 C:\Documents and Settings\Administrator\My Documents\datastructured\main.cpp `queue' has not been declared

can someone solve my problem
this is my coding for main.cpp
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
#include <cstring>
#include <iomanip.h>
#include <fstream.h>
//#include "queue.h"
//#include "list.h"

using namespace std;
const int Total_Minutes=1440;

queue::queue() (const T &id ,const int a_time ,const int s_time)
{


//void Simulation ();
class McDonalds
{
private:
int Customer;
int Customer_Id;
int Arrival_Time;
int Current_Service_Time;
int Hour_Waiting_Time;
int Total_Customers;
int Insert_Node;

McDonalds() { } // private default constructor
public:

McDonalds() : Customer_Id(0) , Arrival_Time(0), Hour_Waiting_Time(0) , Current_Service_Time(0),
Total_Customers(0)
{ }

void Simulation();
};

void McDonalds::Simulation()
{
int Customer_Arrival_Time=1, Total_Waiting=0 , Service_Time=0 ,j=0;
float Average_Waiting_Time=0;

Arrival_Time=1;

srand(time(0));

for (int minute=1 ; minute<=Total_Minutes ; minute+=Customer_Arrival_Time)
{
if (minute==Arrival_Time)
{
++Customer_Id;
Current_Service_Time=(rand()%4+1) + 4;
Customer.Insert_Node(Customer_Id,Customer_Arrival_Time,Current_Service_Time);

Service_Time+=Current_Service_Time;

if (Service_Time>1440)
break;
else
Hour_Waiting_Time+=Current_Service_Time-Customer_Arrival_Time;

Arrival_Time=(rand()%3+1)+minute;
Customer_Arrival_Time=Arrival_Time-minute;
}
}


Total_Customers+=Customer_Id;
Total_Waiting+=Hour_Waiting_Time;

Average_Waiting_Time=Total_Waiting/Customer_Id;

outFile<<"--------------------------------------------------------------"<<endl;
outFile<<" M C D O N A L D S "<<endl;
outFile<<"--------------------------------------------------------------"<<endl;
outFile<<" 2 4 - H o u r S i m u l a t i o n"<<endl;
outFile<<"--------------------------------------------------------------"<<endl<<endl;
outFile<<"=> TOTAL CUSTOMERS : "<<Customer_Id<<endl<<endl;
outFile<<"=> TOTAL WAITING TIME (in minutes) : "<<Total_Waiting<<endl<<endl;
outFile<<"=> TOTAL WAITING TIME (in hour) : "<<Total_Waiting/60<<endl<<endl;
outFile<<"=> AVERAGE WAITING TIME (per customer): "<<Average_Waiting_Time<<endl<<endl;
outFile<<"--------------------------------------------------------------"<<endl<<endl;

if ((Average_Waiting_Time)>3)
outFile<<"The management has to increase the number of counters"<<endl<<endl;
else
outFile<<"The management need not increase the number of counters"<<endl<<endl;

outFile<<"--------------------------------------------------------------"<<endl;

Customer.Display_List(outfile);

}

int main(int argc , char* args[])
{
if (argc<1)
{
cerr<<"INVALID NUMBER OF ARGUMENTS";
return 1;
}

/*open file stream for the input and output
ofstream outFile(args[1], ios::out);

checks that the output file is open or not
if (!outFile)
{
cerr<<"unable to open the output file"<<endl;
return 2;
}
*/
string line;
ifstream myfile1 ("queue.h");
if (myfile1.is_open())
{
while (! myfile1.eof() )
{
getline (myfile1,line);
cout << line << endl;
}
myfile1.close();
}

else cout << "Unable to open file";

string line;
ifstream myfile1 ("queue.h");
if (myfile1.is_open())
{
while (! myfile1.eof() )
{
getline (myfile1,line);
cout << line << endl;
}
myfile1.close();
}

else cout << "Unable to open file";
// McDonalds Customers;

// Customers.Simulation(outFile);
system ("pause");

return 0;
}


int class (int T, int List);
{

template <class T>

class List;

//-------------------------------- N O D E C L A S S -----------------------------------

template <class T>

class Node
{
friend class List<T>;

public:
Node()
{
Service_Time=0;
Arrival_Time=0;
next=NULL;
}

Node(const T &id ,const int a_time ,const int s_time)
{
Customer_Id=id;
Service_Time=s_time;
Arrival_Time=a_time;

next=NULL;
}

Node(const T &id, const int a_time ,const int s_time , Node<T> *n)
{
Customer_Id=id;
Service_Time=s_time;
Arrival_Time=a_time;

next=n;
}

private:
T Customer_Id;
int Service_Time;
int Arrival_Time;

Node<T> *next;
};

//-------------------------------- L I S T C L A S S --------------------------------------

template <class T>

class List
{
public:
List()
{
Head=NULL;
Tail=NULL;
size=0;
}

List(const List<T> &);
~List();
void Delete_List();
void Insert_Node(const T & , const int , const int);
void Delete_Node(const T &);
void Display_List(ofstream&) const;

int Get_size() const
{
return size;
}

List& operator = (const List<T> &);

private:
Node<T> *Head;
Node<T> *Tail;

int size;
};

template <class T>

List<T>::~List()
{
Delete_List();
size=0;
}

template <class T>

void List<T>::Delete_List()
{
if (Head!=NULL)
{
Node<T> *currentptr=Head;
Node<T> *tempptr;

while (currentptr!=0)
{
tempptr=currentptr;
currentptr=currentptr->next;
delete tempptr;
}
}
Head=NULL;
}

template <class T>

void List<T> :: Insert_Node(const T &id , const int a_time ,const int s_time)
{
Node<T> *newptr=new Node<T>(id , a_time , s_time);
assert(newptr!=0);

if (Head==0)
{
Head=newptr;
Tail=newptr;
}
else
{
Tail->next=newptr;
Tail=newptr;
}
size++;
}

template <class T>

void List<T> :: Delete_Node(const T &id)
{
if (Head==0)
{
cout<<"\n error : THE LIST IS EMPTY !";
}
else
{
Node<T> *Fatherptr=Head;
Node<T> *Sonptr=Head->next;

if (Fatherptr->Customer_Id==id)
{
Head=Head->next;
}
else
{
while (Sonptr!=NULL)
{
if (Sonptr->Customer_Id==id)
{
Fatherptr->next=Sonptr->next;
}

Sonptr=Sonptr->next;
Fatherptr=Fatherptr->next;
}
}
}
}

template <class T>

void List<T> :: Display_List(ofstream& outFile) const
{
if (Head==0)
outFile<<"error : THE LIST IS EMPTY ! \n";

else
{
Node<T> *currentptr=Head;

outFile<<"\n\n\t\tC U S T O M E R L I S T"<<endl;
outFile<<"\t\t------------------------"<<endl<<endl;

while (currentptr !=NULL)
{
outFile<<"Customer Id :"<<currentptr->Customer_Id<<endl;
outFile<<"---------------------"<<endl<<endl;
outFile<<"Arrival Time :"<<currentptr->Arrival_Time<<endl;
outFile<<"Service Time :"<<currentptr->Service_Time<<endl<<endl;
currentptr=currentptr->next;
}
}
}

template <class T>

List<T> :: List(const List<T> &original)
{
size=original.size;

Node<T> *ptr=original.Head;
Node<T> *newptr , *lastptr;

while(ptr!=NULL);
{
newptr=new Node<T>(ptr->Customer_Id , ptr->Waiting_Time , ptr->Service_Time);
assert(newptr!=0);

if (Head==0)
Head=newptr;
else
lastptr->next=newptr;

lastptr=newptr;
ptr=ptr->next;
}
}

template <class T>

List<T>& List<T> :: operator=(const List<T> &original)
{
if (this!=&original)
{
deleteList();

size=original.size;
Head=0;
Node<T> *ptr=original.Head;
Node<T> *newptr , *lastptr;

while(ptr!=0);
{
newptr=new Node<T>(ptr->Customer_Id , ptr->Waiting_Time , ptr->Service_Time);
assert(newptr!=0);

if (Head==0)
Head=newptr;
else
lastptr->next=newptr;

lastptr=newptr;
ptr=ptr->next;
}

}
return ptr;
}



newptr
Last edited on
The messages actually tell you what's wrong. Have you read them?

Line 1. iostream.h is deprecated, use iostream instead.
Lin 14. queue is not recognised because you commented out queue.h a few line earlier.
Topic archived. No new replies allowed.