Allright, here is my code.
My customer/data class (basically the class that is encapsulated by the node)
Code:
Customer :: Customer (int id, int items, int seconds)
{
customerValues[0] = id;
customerValues[1] = items;
customerValues[2] = seconds;
customerValues[3] = items;
}
int* Customer :: getCustomerValues()
{
return customerValues;
}
My Node class
Code:
Node :: Node ()
{
link = NULL;
}
Customer* Node :: getCustomer ()
{
return current;
}
void Node :: setNextLink (Node* next)
{
link = next;
}
void Node :: setCustomer(Customer* incoming)
{
current = incoming;
}
Node* Node :: getLink()
{
return link;
}
My queue (now, my pop function doesn't really pop it off yet, I want to return the correct values from my customer before I start popping off values, you'll see what I mean...)
Code:
Queue :: Queue (string type)
{
queueSize = 0;
frontNode = new Node;
backNode = frontNode;
frontNode->setNextLink(NULL);
queueType = type;
}
bool Queue :: isEmpty()
{
return frontNode == backNode;
}
void Queue :: push(Customer incoming)
{
backNode->setCustomer(&incoming);
backNode->setNextLink(new Node);
backNode=backNode->getLink();
backNode->setNextLink(NULL);
queueSize++;
}
Customer Queue :: pop()
{
// Node *nodeHolder;
if (isEmpty())
cout << "Queue is Empty!";
else
{
Customer frontCustomer = *frontNode->getCustomer();
cout << frontCustomer.getCustomerValues()[0];// if I index it with zero, I get the correct value
cout << (frontCustomer.getCustomerValues()[2]); //now if I try doing this, I get funny values
return frontCustomer;
/*nodeHolder = frontNode;
frontNode = frontNode->getLink();
delete nodeHolder;
queueSize--;
*/
}
}
int Queue :: size()
{
return queueSize;
}
and finnally my driver for it, just for testing, it doesn't really do much yet
Code:
main()
{
string y = "express";
Customer one (100,100,100);
Queue lane(y);
lane.push(one);
lane.pop();
}
I think my problem deals with how I'm referencing my array, I dunno.