and in general std::list(http://www.cplusplus.com/reference/stl/list/) is a good idea
I think you should do this:
CPP
Node* List::at(int index)
{
Node *temp = head;
int i;
for(i = 0; i < index; ++i)
{
temp = temp->next;
}
return temp;
}
H
Node* at(int index);
Can you post your code? <<snip>>
#include <string>
will help :)
i would use:
- std::queue
- instead of char sender[20],recipient[20],content[100],date[10]; -> std::string
- strcpy would obsolte with std:.string
- instead of:
void receiveMessage(Que q)
{
Message m=q.remove();
if(strcmp(m.sender," ")!=0)
{
cout<<"\nDate: "<<m.getDate();
cout<<"\nFrom: "<<m.sender;
cout<<"\nTo: "<<m.recipient;
cout<<"\nContent:"<<m.content;
}
else
cout<<"\nNo messages to receive.";
}
void receiveMessage(Que q)
{
Message m=q.remove();
if(strcmp(m.sender," ")!=0)
{
cout<<"\nDate: "<<m.getDate();
cout<<"\nFrom: "<<m.sender;
cout<<"\nTo: "<<m.recipient;
cout<<"\nContent:"<<m.content;
}
else
throw CNoMessageReceived("No messages to receive.");
}
or
eError receiveMessage(Que q)
{
Message m=q.remove();
if(strcmp(m.sender," ")!=0)
{
cout<<"\nDate: "<<m.getDate();
cout<<"\nFrom: "<<m.sender;
cout<<"\nTo: "<<m.recipient;
cout<<"\nContent:"<<m.content;
}
else
return ERR_NO_MSG_RCV;
}
- use & Reference
eError receiveMessage(Que q)
BETTER:
eError receiveMessage(Que &q)
- cout in class is always bad design, except your class method called "PrintDebugXYZ"
enough for today :)
"A?%%CNT1%%" should help