I am currently attempting to implement a Doubly Linked List for a Data Structures class.
I currently have implemented a generic Node* class and wanted to hold an instance of another class Student(int i, int j) that I have implemented.
This is what i'm attempting to do in my main method:
Student student1 = Student(10,11);
Node<Student()> node1 = Node<Student()> (student1);
This is the error I am receiving. Everything worked absolutely fine when the Node was holding a primitive data type like an int but i'm unsure how to account for the difference between storing an int and storing a Student object.
I would love any insight or pushes in the right direction. Thank you.
Here is my implementation of Node.
#ifndef NODE_H
#define NODE_H
template <class T>
class Node
{
public:
Node();
Node(T k);
virtual~Node();
T key;
Node<T>* prev;
Node<T>* next;
};
#endif
//default constructor
template <class T>
Node<T>::Node()
{
prev = NULL;
next = NULL;
}
template <class T>
Node<T>::Node(T k)
{
prev = NULL;
next = NULL;
key = k;
}
template<class T>
Node<T>::~Node()
{
//implement
}
Student.cpp
#include "Student.h"
Student::Student()
{
mArrivalTime = 0;
mTimeNeeded = 0;
}
Student::Student(int arrivalTime, int timeNeeded)
{
mArrivalTime = arrivalTime;
mTimeNeeded = timeNeeded;
}
Student::~Student()
{
//implement
}
int Student::getArrivalTime()
{
return mArrivalTime;
}
int Student::getTimeNeeded()
{
return mTimeNeeded;
}
Student.h
#ifndef STUDENT_H
#define STUDENT_H
using namespace std;
class Student
{
private:
int mArrivalTime;
int mTimeNeeded;
public:
Student();
Student(int arrivalTime, int timeNeeded);
~Student();
int getArrivalTime();
int getTimeNeeded();
};
#endif