0

I have a problem on getting the nth list item( function: DataType get(int n) const ),though it may seem easy.

here is my code..

```
#ifndef ORDERED_LIST
#define ORDERED_LIST
#include <fstream>
using namespace std;
template <class DataType>
class OrderedList
{
public:
OrderedList();
~OrderedList();
void clear();
DataType get(int n) const;
void insert(const DataType & dataVal);
int size();
void showAscending();
private:
class Node;
typedef Node * NodePointer;
class Node
{
public:
DataType data; // element storage
NodePointer prev; // pointer to previous node
NodePointer next; // pointer to next node
Node(const DataType & dataValue,
NodePointer back = 0, NodePointer fwd = 0)
{
data = dataValue;
prev = 0;
next = 0;
};
};
NodePointer first, last; // pointers to first and last nodes
int numNodes; // number of existing nodes
};
template <class DataType>
OrderedList<DataType>::OrderedList(): first(0), last(0), numNodes(0) {}
template <class DataType>
OrderedList<DataType>::~OrderedList()
{
NodePointer nPtr = first;
while (nPtr != 0)
{
first = nPtr->next;
delete nPtr;
nPtr = first;
}
}
template <class DataType>
void OrderedList<DataType>::clear()
{
while (size() > 0) remove(1);
}
////..............Get method.......................//////
template <class DataType>
DataType OrderedList<DataType>::get(int n) const
{
}
```

I have a problem on this method..i am confused what do i need to return??

is that

return numNodes;

or

first node or last node

or data value..

Note:The list values are in a double linked list. The list positions are

numbered starting at 1 and the list values are in ascending order (the value

at position 2 is greater than or equal to the value at position 1, the value

at position 3 is greater than or equal to the value at position 2, etc.)

Any help would be highly appreciate..