The program I'm creating keeps coming up with an unresolved external symbol error and I can't figure out where I am going wrong.
The errors that are coming up are:
error LNK1120: 1 unresolved externals
error LNK2019: unresolved external symbol "public: __thiscall linkedList::~linkedList(void)" (??1linkedList@@QAE@XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'list''(void)" (??__Flist@@YAXXZ)
Any help would be greatly appreciated.
source.cpp
#include <iostream>
#include <string>
#include "LList.h"
#include "vehicle.h"
#include "windows.h"
#include <iomanip>
using namespace std;
linkedList list;
int main()
{
char menuSelect;
do
{
menuSelect = NULL;
cout << "Please press one of the following options:";
cout << "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";
cout << "\n1. List all vehicles";
cout << "\n2. Add a vehicle (Car or Van)";
cout << "\n3. Remove a vehicle";
cout << "\n4. Book a car";
cout << "\n5. Book a van";
cout << "\n6. Display a vehicle's details";
cout << "\n7. List all cars currently not rented";
cout << "\n8. List all 5-door cars";
cout << "\n9. List all Ford vans currently rented";
cout << "\n0. Quit";
cout << "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n";
cin >> menuSelect;
void addNode();
void deleteNode();
void getVehicles();
switch (menuSelect)
{
case '1':
getVehicles(); //displays all vehicles in the list.
break;
case '2':
addNode(); //allows the user to add another vehicle.
break;
case '3':
deleteNode(); //allows the user to delete a vehicle.
break;
case '4':
//allows the user to book a car.
break;
case '5':
//allows the user to book a van.
break;
case '6':
//allows the user to select a vehicle and show it's details.
break;
case '7':
//lists all the vehicles that are currently not rented.
break;
case '8': //lists all cars that are 5 door.
break;
case '9': //lists all of the Ford vans that are currently rented.
break;
case '0':
system("pause");
return 0;
break;
default: cout << "\n" << menuSelect << " is not a valid selection.";
cout << endl;
}
}
while (menuSelect != 0);
return 0;
}
void addNode()
{
node* newNode = new node;
cout << "Is it a car or van?: \n";
cin >> newNode->make;
cout << "\nEnter model: \n";
cin >> newNode->model;
cout << "\nEnter engine size: \n";
cin >> newNode->engine;
cout << "\nEnter registration number: \n ";
cin >> newNode->registration;
list.insertNode(newNode);
}
void deleteNode()
{
char searchData;
cout << "Enter the registration plate to be deleted: ";
cin >> searchData;
if (list.deleteNode(searchData))
cout << "\nNode deleted. \n\n\n";
cout << "\nThe registration plate is not in the list\n\n";
}
void getVehicles()
{
string searchData;
list.displayList();
}
LList.h
#include <string>
#include "vehicle.h"
#include "windows.h"
#include <iostream>
using namespace std;
struct node
{
int registration;
double engine;
string model;
string make;
node* nextNode;
int data;
};
class linkedList
{
private:
node* head;
public:
linkedList() { head = NULL; }
void insertNode(node*);
void searchNode(int);
bool deleteNode(int deleteVehicle);
void displayList();
~linkedList();
};
Llist.cpp
#include <iostream>
#include "windows.h"
#include <string>
#include "LList.h"
#include "vehicle.h"
#include <iomanip>
using namespace std;
vehicle.h
#pragma once
#include <string>
#include "windows.h"
//#include "LList.h"
template<class registration = int>
class Vehicle
{
public:
typedef enum { Car, Van } vehicleType;
protected:
vehicleType make;
char model;
bool rent;
double engineSize;
int registration;
public:
Vehicle(vehicleType make) : model(""), registration(reg), engineSize(engine), make(make), rented(false){}
char getMakeModel();
bool getRented;
bool setRented(bool rent);
int getEngineSize();
int getRegistration();
~Vehicle();
void listVehicle();
void removeVehicle(int deleteVehicle);
void addVehicle();
void bookVehicle();
void displayDetails(int registration);
void listNonRented();
void listFiveDoor();
void listRentedFordVan();
};
void linkedList::insertNode(node* newNode)
{
newNode->nextNode = head;
head = newNode;
}
bool linkedList::deleteNode(int deleteVehicle)
{
node* beforeNode = head;
node* thisNode = head;
bool found = false;
while ((thisNode != NULL) && !found)
{
if (thisNode->data == deleteVehicle)
found = true;
else
{
beforeNode = thisNode;
thisNode = thisNode->nextNode;
}
}
if (found)
{
if (thisNode == head)
{
node* oldHead = head;
head = head->nextNode;
delete oldHead;
}
else
{
beforeNode->nextNode = thisNode->nextNode;
delete thisNode;
}
return true;
}
return false;
}
void linkedList:: displayList()
{
node* thisNode = head;
if (head == NULL)
{
cout << "\nThe list is empty\n";
}
else
cout << "\tMake\tModel\tRegistration Number\tEngine Size\tRented?";
do
{
cout << setw(30) << left << thisNode->make;
cout << setw(25) << left << thisNode->model;
cout << setw(20) << left << thisNode->registration;
cout << setw(15) << left << thisNode->engine;
//cout << setw(10) << left << thisNode->rented;
} while (thisNode != NULL);
{
cout << "\n\n";
}
}
void linkedList::insertNode(node* newNode)
etc. should be in Llist.cpp instead of vehicle.h. – mch