I am trying to define an object of mylist inside the mylist class.
here is my code:
mlist.h
#ifndef MLIST_H
#define MLIST_H
#endif // MLIST_H
#include "mylist.h"
template <class T> class mlist
{
protected:
T item = 0;
mylist<T> next = 0;
};
mylist.h
#ifndef MYLIST_H
#define MYLIST_H
#include "mlist.h"
template <class T> class mylist : mlist<T>
{
private:
T item;
mylist<T>* next;
// --- some functions ---
};
#endif // MYLIST_H
the error:
error: 'mylist' does not name a type
mylist next = 0;
my question: What is going wrong and what is the correct way on doing this?