Code:
Void returnLastItem(ItemType& item)
{
int location=0;
if(//the pointer in the last item is NULL then execute(i dont know how to write this))
item = info[location];//i think this is to print
}
|
Go4Expert Member
|
|
| 17Nov2008,22:00 | #11 |
|
mmm ok..i'll have a second try
Code:
Void returnLastItem(ItemType& item)
{
int location=0;
if(//the pointer in the last item is NULL then execute(i dont know how to write this))
item = info[location];//i think this is to print
}
|
|
Go4Expert Member
|
|
| 18Nov2008,00:00 | #12 |
|
plz
heeeeeeeeeeeeeeeeeeeeeeeeeeeelp im dying here..plz help |
|
Mentor
|
![]() |
| 18Nov2008,04:00 | #13 |
|
I think you're assuming this is harder than it really is.
You've been given the prototype. Why have you changed the return type to Void? You can't return something from a void function. What is length? HINT - THIS IS A MAJOR CLUE What is info[]? HINT - THIS IS ANOTHER MAJOR CLUE What does the function have to return? Do you think it might have something to do with info[] and length? HINT - YES AND YES. Why do you think you need to test if the pointer in the last item is NULL? |
|
Go4Expert Member
|
|
| 18Nov2008,09:54 | #14 |
|
is it right now?
Code:
ReturnLastItem (item,info)
{
int location=MAX-1;
return(info[location]);
}
|
|
Go4Expert Founder
|
![]() |
| 18Nov2008,09:59 | #15 |
|
Yes
|
|
Go4Expert Member
|
|
| 18Nov2008,10:11 | #16 |
|
thanks..put how can i compile it now?
|
|
Go4Expert Founder
|
![]() |
| 18Nov2008,10:15 | #17 |
|
This function alone will not compile
|
|
Go4Expert Member
|
|
| 18Nov2008,10:19 | #18 |
|
could u plz tell me what to write because i need to compile it..
i think these go on top: Code:
#include <iostream.h>
#include <string.h>
class unsorted list
{
private:
public:
};
|
|
Mentor
|
![]() |
| 18Nov2008,13:35 | #19 |
|
Could you answer some questions please? Without the answers I have no way of saying whether you're right or not.
1. Why have you changed the function from the prototype? Remember at the top you said "the prototype of the function should be ItemType ReturnLastItem();", but for some reason you've changed it to "ReturnLastItem (item,info)" (which is wrong on four counts: (a) there is no return type; (b) there is no type for item (and if this is a class member why do you want to pass it in as a new variable?); (c) there is no type for info (and if this is a class member etc); (d) it does not match the prototype you've been given. 2. What is length? 3. What is info[]? And now a new one from your latest code: 4. What is MAX? In terms of the other code you should add, remember the statement you made earlier: "the whole question says that we should add a member function ReturnLastItem () to the UnsortedType ADT". So it's not what code you should wrap around ReturnLastItem() itself, but what code you should insert ReturnLastItem() into. Do you have a source/header file for UnsortedType? |
|
Go4Expert Member
|
|
| 18Nov2008,22:54 | #20 |
|
Hi
no i dont have a source file and im really so stressed out..i've been trying to solve this question for several days and the due date is tomorrw.. the length is undetermined..i supposed it is an integer called max and item = info[location] is used to retrieve the item and save it in item..so when we get the cout we will say cout<<item; could u plz help me this time to get the result |