#ifndef LIST_H
#define LIST_H
template <typename MyType>
class MyList
{
private:
struct Node
{
MyType item;
Node* next;
};
private:
Node* m_head;
size_t m_size;
private:
Node* find(int ind) const;
public:
MyList();
~MyList();
MyList(const MyList& ob);
//MyList& operator=(const Mylist& ob);
bool isEmpty() const;
size_t size() const;
//void insert(int ind, MyType item);
//void remove(int ind);
};
//
//
//
//
//
template <typename MyType>
typename MyList<MyType>::Node* MyList<MyType>::find(int ind) const
{
if( ind < 1 || ind > size() )
return nullptr;
else
{
Node* cur = m_head;
for(int i = 1; i < ind; ++i)
{
cur = cur->next;
}
return cur;
}
return nullptr;
}
#endif
http://www.cplusplus.com/articles/z13hAqkS/