Easy,
1. You have 'front' defined as pointer and you're using the '.', think of '->'
2. You are accessing name, but name is defined in class 'info'
i could fix it but it looks like you'll get it.
INTEL
ok, I changed the output lines to this...
cout<<"MM ITEMS: "<<mm.items<<endl;
cout<<"FP ITEMS: "<<fp.items<<endl;
cout<<"TXT ITEMS: "<<txt.items<<endl;
cout<<"CTIME: "<<cTime<<endl;
cout<<"Front Name: "<<mm.front->name<<endl;
Now it prints out the number of items in each queue but the last line only prints out a bunch of nonsense and I get an access violation error.
It sounds like my pointer is pointing somewhere it shouldn't be. What is going on?
I also changed around the queue class and the nodetype class to this...
class NodeType
{
public:
NodeType* next;
NodeType* back;
int switches, fTime, sTime;
int length, aTime;
string name;
string type;
string urgent;
string getName()
{
return name;
}
NodeType()
{
switches=0;
fTime=0;
sTime=0;
};
~NodeType()
{
};
class Queue
{
public:
Queue();
~Queue();
void makeEmpty();
void addFrontNode(NodeType newJob);
void addRearNode(NodeType newJob);
void delNode(NodeType &delJob);
bool isEmpty() const;
bool isFull() const;
int getItems();
int items;
NodeType* front;
NodeType* rear;
};
Also, please look at my addNode fuction. Maybe its not actually putting the items into the queue?
void Queue::addRearNode(NodeType newJob)
{
if (isFull())
throw FullQueue();
else
{
NodeType* newNode;
newNode = new NodeType;
newNode = &newJob;
newNode->next = NULL;
if (rear == NULL)
front = newNode;
else
rear->next = newNode;
rear = newNode;
items++;
}
}
void Queue::addFrontNode(NodeType newJob)
{
if (isFull())
throw FullQueue();
else
{
NodeType* newNode;
newNode = new NodeType;
newNode = &newJob;
newNode->next = NULL;
if (front ==NULL)
rear = newNode;
else
front->next = newNode;
front = newNode;
items++;
}
}
Any Help?