queue and objects
First this is a homework assignment, so I don't want the answer just a point in the right direction.
The problem is a bank simulation. I have 3 classes: Tellers, Customers, and InLine. The line is the queue.
The customers class has an array of objects defined in main like this:
My question is this, is it possible to insert an object customer into the queue? I have tried many ways but nothing seems to work.
line.enqueue(x); //i would like for x to be a customer object.
Does this make sense to anyone, if so please point me in the right direction.
Did you mean that the InLine class has an array of Customers (it wouldn't make sense for the Customers class to have an array of Customers)?
Yes it would be possible. You'd have to keep track of the start and end of the line, so you know which objects in the array are in line and which are dummies that aren't valid.
I would rename your classes "Teller" and "Customer" because an object of those classes represents one teller or one customer. Then name your array "customers".
However, as Daved pointed out, your Inline class should contain the array. In addition, the Inline class will contain the methods to add customers to the array and keep track of how many customers there are in the array.
//assign a customer to the array:
customers = customer3;
You also need to be aware of what happens when you pass an object by value to a function vs. what happens when you pass an object by reference to a function. You always want to pass objects by reference to avoid copying.