In the class, in my header file, in the private section of the class I have
Heap_PriorityQueue<Passenger> oldBoardingQueue;
I have #include "Heap_PriorityQueue.h"
in both the header and the cpp just to be safe.
I haven't even started using it in my cpp file, yet when I try to compile the cpp file throws up a bunch of:
undefiend reference to 'Heap_PriorityQueue<Passenger>::(insert function for Heap_PriorityQueue class isEmpty, add, etc.)
Followed by several
undefined reference to 'non-virtual thunk to Heap_PriorityQueue<Passenger>::(Heap_PriorityQueue functions again)
Unsure of how to proceed. Am I declaring incorrectly?
Edit:
Passenger is another class for creating Passenger objects holding the passenger's data (name, row, priority/key, etc).
Not sure what's meant by 'linker command' (I'm a student/newb) but the makefile for airworthy.cpp and airworthy.h files are as follows:
Airworthy.o: Airworthy.cpp Airworthy.h Heap_PriorityQueue.h NotFoundException.h PrecondViolatedExcep.h Passenger.h
g++ -std=gnu++11 -ggdb -c Airworthy.cpp
Airworthy.h is as follows:
#ifndef AIRWORTHY_H
#define AIRWORTHY_H
#include "Heap_PriorityQueue.h"
#include "Passenger.h"
using namespace std;
class Airworthy
{
private:
int oldBoardingSeconds;
int randomBoardingSeconds;
Heap_PriorityQueue<Passenger> oldBoardingQueue;
Heap_PriorityQueue<Passenger> randomBoardingQueue;
Passenger thisPassenger;
public:
Airworthy();
void inputFileData(ifstream& inputFile);
void loadQueue(ifstream& inputFile, ofstream& outputFile);
void runSim();
void setOldBoardingPriority();
void setRandomBoardingPriority();
};
#endif
Just realized that the error hones in on the first use of the Airworthy constructor which I've just had empty for now. Here's the first part of Airworthy.cpp
#include "Airworthy.h"
#include "Heap_PriorityQueue.h"
#include "Passenger.h"
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <cstdlib>
using namespace std;
Airworthy::Airworthy()
{
}
Tried putting different things inside the constructor (including the Heap_PriorityQueues) but doesn't seem to make a difference. Calling the constructor in the main cpp file makes that file also generate the same errors.
Heap_PriorityQueue.h is as follows:
#ifndef _HEAP_PRIORITY_QUEUE
#define _HEAP_PRIORITY_QUEUE
#include "ArrayMaxHeap.h"
#include "PriorityQueueInterface.h"
template<class ItemType>
class Heap_PriorityQueue : public PriorityQueueInterface<ItemType>,
private ArrayMaxHeap<ItemType>
{
public:
Heap_PriorityQueue();
bool isEmpty() const;
bool add(const ItemType& newEntry);
bool remove();
/** @pre The priority queue is not empty. */
ItemType peek() const throw(PrecondViolatedExcep);
}; // end Heap_PriorityQueue
#endif
I'm at my wits end, I've been trying to make this damned thing work for hours now.