0

Im having trouble implementing this Queue simulation. This simulation basically estimates how long a student has to wait in line for lunch at my high school.

I get the following messages when trying to compile

[C++ Error] davislunch.cpp(30): E2034 Cannot convert 'line *' to 'line::node *'

Heres the source:

davislunch.h

class student
{
     private:
          long arrive;
          int process;
     public:
          student() { arrive = process = 0; }
          void set(long when);
          long when() const { return arrive; }
          int proc_time() const { return process; }
};

typedef student PEOPLE;

class line
{
     private:
          struct node{ PEOPLE people; struct node *next; };
          enum{LINESZ = 10};
          line *front;
          line *back;
          int ppl;
          const int linesz;
          line(const line &l) : linesz(0) {}
          line &operator = (const line *l) { return *this; }
     public:
          line(int ls = LINESZ);
          ~line();
          bool isEmpty() const;
          bool isFull() const;
          int lineCount() const;
          bool add(const PEOPLE &people);
          bool del(PEOPLE &people);
};

davislunch.cpp

line::line(int ls) : linesz(ls)
{
     front = back = 0;
     ppl = 0;
}

line::~line()
{
     node *temp;
     while(front != 0)
     {
          temp = front;
          front = front->next;
          delete temp;
     }
}

bool line::isEmpty() const
{
     return ppl == 0;
}

bool line::isFull() const
{
     return ppl == linesz;
}

int line::lineCount() const
{
     return ppl;
}

bool line::add(const PEOPLE &people)
{
     if(isFull())
          return false;
     node *add = new node;
     if(add == 0)
          return false;
     add->people = people;
     add->next = 0;
     ppl++;
     if(front == 0)
          front = add;
     else
          back->next = add;
     back = add;
     return true;
}

bool line::del(PEOPLE &people)
{
     if(front == 0)
          return false;
     people = front->people;
     ppl--;
     node *temp = front;
     front = front->next;
     delete temp;
     if(ppl == 0)
          back = 0;
     return true;
}

void student::set(long when)
{
     std::srand(std::time(0));
     process = std::rand() % 3 + 1;
     arrive = when;
}

Im using Borland C++ Builder 6.


Thanks is advanced

2
Contributors
1
Reply
3
Views
11 Years
Discussion Span
Last Post by Rashakil Fol
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.