Arrival.o: In function `NodeItem':
/home/jonyb/Desktop/A3-Q2/NodeItem.h:5: undefined reference to `vtable for NodeItem'

Arrival.o: In function `~Event':
/home/jonyb/Desktop/A3-Q2/Event.h:8: undefined reference to `NodeItem::~NodeItem()'

Event.o:(.rodata._ZTI5Event[typeinfo for Event]+0x8): undefined reference to `typeinfo for NodeItem'


These 3 errors repeat themselves for all my files accessing NodeItem.h and NodeItem.cpp

Now I've looked around and all I could find was that I need to have a body (albeit empty) for my NodeItem virtual destructor, I do have it for NodeItem. I have to admit the whole destructor thing has got me confused since all the example I've seen are either empty of only contain a cout or cerr saying it was called.

NodeItem.h, the abstact item a List/Queue Node contains

#ifndef NODEITEM_H

#define NODEITEM_H
using namespace std;

class NodeItem {
public:
	virtual int compareTo(NodeItem* item)=0;

	virtual void print()=0;
	virtual ~NodeItem(); 

};
#endif

NodeItem.cpp

#include "NodeItem.h"
NodeItem::~NodeItem(){}

Event.h, subclass of NodeItem

#ifndef EVENT_H

#define EVENT_H
#include "NodeItem.h"
#include "Train.h"
using namespace std;

class Train;
class Event : public NodeItem {

	protected:
	int time;
	Train * train;

	public:
	int compareTo(NodeItem* item);
	virtual void print()=0;
	virtual void activate()=0;
	void setTime(int time); 
	int getTime();
	void setTrain(Train* train);
	Train* getTrain();

};
#endif

Event.cpp

#include "Event.h"
#include "NodeItem.h"
using namespace std;


int Event::compareTo(NodeItem* item)
{
	int ReturnVal;
	Event* EventItem = (Event*) item;

	if(this->time < EventItem->time)
	{
		ReturnVal = -1;
	}
	else if(this->time > EventItem->time)
	{
		ReturnVal = 1;
	}
	else //(this.time == EventObj.time)
	{
		// we now compare the passengers
		ReturnVal = this->train->compareTo(EventItem->train);
	}
	
	return ReturnVal;
}

void Event::setTime(int time) {
	this->time = time;
}
int Event::getTime() {
	return time;
}
void Event::setTrain(Train* train) {
	this->train = train;
}
Train* Event::getTrain() {
	return train;
}

Arrival.h, subclass of Event
One of the classes calling NodeItem

#ifndef ARRIVAL_H

#define ARRIVAL_H
#include "Event.h"
using namespace std;

class Arrival : public Event{
public:
	Arrival();
	Arrival(int time, Train * newTrain);
	void print();
	void activate();
};
#endif

Arrival.cpp

#include <iostream>
#include "Arrival.h"
#include "InSwitch.h"
#include "WideVar.h"
#include "Input.h"
#include "const.h"
using namespace std;


Arrival::Arrival(){}


Arrival::Arrival(int currTime, Train* newTrain)
{
	time=currTime;
	train=newTrain;
}

void Arrival::activate()
{
	Train* curr = this->train;
	
	wideVar::inPush(curr);

	if(wideVar::getInLength() == 1 && wideVar::freeDocksReturn() > 0) // it is the first and only item at this point
	{
		InSwitch* newIS = new InSwitch(this->time+IN_SWITCH_TIME, curr);
		wideVar::insertEvent(newIS);
		wideVar::freeDocksNumDown();
	}

		
	this->print();
	Input::readInNext();
		
}

void Arrival::print(){
	Train* curr = this->train;
	cout << "Time: " << this->time << "Train: " << curr->getId() << " has arrived, it will need: " << curr->dropOffTime << " time units" << endl;
}

Thank you very much to whoever is able to help me, those 3 errors are just repeating themselves endlessly throughout my files and it's driving me insane!

I swear I'm not usually that dumb... acursed midterms and lengthy projects!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.