Linked List Retrieve Method

Reply

Join Date: May 2005
Posts: 42
Reputation: TimC is an unknown quantity at this point 
Solved Threads: 0
TimC TimC is offline Offline
Light Poster

Linked List Retrieve Method

 
0
  #1
Dec 15th, 2005
what I am trying to do is retrive the "status" back to my main prog of the status of a patient.

I thought it was a simple case of S.retrieve(index of person I was looking for) and I would recive the status (which is an integer) back to my main function. everytime I try to complie it will not compile. Any suggestions on how to tackle it?



Patient P; declaration of object
Sequence S; declaration of patient

I have a patient object with methods

void patient::set_status(int aStatus)
{
status=aStatus;
}

int patient::get_status()
{
return status;
}


I have a Linked list with method


SeqItemType Sequence::retrieve(int index)
{
if ((index < 1) || (index > size())){
// can't retrieve something that isn't there
}
ListNode *cur = find(index);
return cur->item.get_status();
}
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 466
Reputation: winbatch is on a distinguished road 
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Re: Linked List Retrieve Method

 
0
  #2
Dec 15th, 2005
Is it just a typo in the post or is the object called Patient with a capital P and the class methods are using patient with a lowercase p?
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 42
Reputation: TimC is an unknown quantity at this point 
Solved Threads: 0
TimC TimC is offline Offline
Light Poster

Re: Linked List Retrieve Method

 
0
  #3
Dec 16th, 2005
I figured this one out myself or should I say the solution works!!!

Change SeqItemType to an int. then the method will return an int which is what i wanted and I can use an if/case statement from here.

SeqItemType Sequence::retrieve(int index)
{
if ((index < 1) || (index > size())){
// can't retrieve something that isn't there
}
ListNode *cur = find(index);
return cur->item.get_status();
}
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 466
Reputation: winbatch is on a distinguished road 
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Re: Linked List Retrieve Method

 
0
  #4
Dec 16th, 2005
What's the point of this statement? You don't return something else instead and you don't perform any logic...

if ((index < 1) || (index > size())){
// can't retrieve something that isn't there
}
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 42
Reputation: TimC is an unknown quantity at this point 
Solved Threads: 0
TimC TimC is offline Offline
Light Poster

Re: Linked List Retrieve Method

 
0
  #5
Dec 16th, 2005
Good point. We have a lab tomorrow morning and I'll ask the lecturer. Sometimes I reckon the lecturer just pulls the notes down off the net somewhere and just throws them out to us.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC