![]() |
| ||
| Linked List Retrieve Method 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(); } |
| ||
| Re: Linked List Retrieve Method 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? |
| ||
| Re: Linked List Retrieve Method 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(); } |
| ||
| Re: Linked List Retrieve Method 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 } |
| ||
| Re: Linked List Retrieve Method 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. |
| All times are GMT -4. The time now is 11:32 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC