0
elsa87's Avatar, Join Date: Oct 2008
Go4Expert Member
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
}
0
elsa87's Avatar, Join Date: Oct 2008
Go4Expert Member
plz
heeeeeeeeeeeeeeeeeeeeeeeeeeeelp
im dying here..plz help
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
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?
0
elsa87's Avatar, Join Date: Oct 2008
Go4Expert Member
is it right now?
Code:
ReturnLastItem (item,info)
{
int location=MAX-1;
return(info[location]);
}
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Yes
0
elsa87's Avatar, Join Date: Oct 2008
Go4Expert Member
thanks..put how can i compile it now?
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
This function alone will not compile
0
elsa87's Avatar, Join Date: Oct 2008
Go4Expert Member
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:
	
};
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
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?
0
elsa87's Avatar, Join Date: Oct 2008
Go4Expert Member
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