For my homework for my C ++ class, I need to create a Linked List data structure. At the moment I have two classes. List class (template class) and Link class. The Link class is nested in the List class, however I am trying to define it in a separate header file. The problems I'm experiencing are related to my lack of understanding of how the binding process works. Here is what I have.
List Content .h
#ifndef _LIST_H_
#define _LIST_H_
template <class T>
class List
{
protected:
class Link;
public:
List() : _head(nullptr) { }
~List() { }
void PushFront(T object)
{
}
protected:
Link* _head;
};
#endif
Link.h Content
#ifndef _LINK_H_
#define _LINK_H_
#include "List.h"
template <class T>
class List<T>::Link
{
public:
Link(T object, Link* next = nullptr)
: _object(object), _next(next) { }
~Link() { }
private:
T _object;
Link* _next;
};
#endif
Content main.cpp (entry point)
#include "List.h"
int main()
{
int b = 5;
List<int> a;
a.PushFront(b);
}
I am sure this is a communication error that is occurring. Similar to this error on the Microsoft website that I looked at ( http://msdn.microsoft.com/en-us/library/4ce3zbbc.aspx ), I'm not sure how to resolve it.
user1114264