1
1337-chixor;)
Hi guys,
I'm dealing with, probably, easy problem, however I'm not sure what to
do and whether my way of thinking is correct..
The task is to implement a list of object of a class ListOfElements
and then implement a function that will reverse the order of the
elements on the list, but the function should look like this:
ListOfElements reverse (const ListOfElements&)
As far as I understand I should create a list of these objects, which
I know how to do. I have difficulties with the function reverse. What
does it realy mean that as parameter it takes ListOfElements& ? Is
this a reference to the first object, ie. a pointer to the first
object?
say we have the following:
class ListOfElements
{
private:
int data;
ListOfElements * next; //pointer to the next element on the
list
public:
ListOfElements();
~ListOfElements();
addNewElement (int new_data);
}
ListOfElements * head = NULL; pointer to the first element
How can I now implement reverse? The algorithm of the reversing is not
the problem, I don't know what to do with the constant reference and
returning of an object...
I'm dealing with, probably, easy problem, however I'm not sure what to
do and whether my way of thinking is correct..
The task is to implement a list of object of a class ListOfElements
and then implement a function that will reverse the order of the
elements on the list, but the function should look like this:
ListOfElements reverse (const ListOfElements&)
As far as I understand I should create a list of these objects, which
I know how to do. I have difficulties with the function reverse. What
does it realy mean that as parameter it takes ListOfElements& ? Is
this a reference to the first object, ie. a pointer to the first
object?
say we have the following:
class ListOfElements
{
private:
int data;
ListOfElements * next; //pointer to the next element on the
list
public:
ListOfElements();
~ListOfElements();
addNewElement (int new_data);
}
ListOfElements * head = NULL; pointer to the first element
How can I now implement reverse? The algorithm of the reversing is not
the problem, I don't know what to do with the constant reference and
returning of an object...