Getting Error LNK2019 due to creating a vector array from structure header?
-
04-06-2021 - |
سؤال
I'm am attempting to create a vector of arrays from inputting files and then loading the vector into my main. I am also attempting to use the same vector throughout my program. When I compile, however, I get a bunch of Error LNK2019s. I think I have an idea as to where this is happening but I am unsure as to why. Could someone help or explain? Thanks!
#include <iostream>
#include <string>
#include <vector>
#include "Database.h"
#include "Registration.h"
#include "Competition.h"
#include "Events.h"
#include "CompPop.h"
#include "PushRegistration.h"
using namespace std;
void main()
{
vector<Competition> myVector = CompPop();
vector<Registration> myRegistration = PushRegistration();
Database home(myVector, myRegistration);
home.Menu();
system("pause");
}
Seems to occur at: 1. vector < Competition > myVector 2. vector< Registration> myRegistration
and these are the error messages I am getting
error LNK2001: unresolved external symbol "public: __thiscall Registration::~Registration(void)" (??1Registration@@QAE@XZ)
and
error LNK2001: unresolved external symbol "public: __thiscall Database::~Database(void)" (??1Database@@QAE@XZ)
My Compop header, reads from a file and stores the contents into a vector of Competition (similar to my PushRegistration header)
#pragma once
#include <fstream>
#include <sstream>
#include <iostream>
#include <string>
#include <vector>
#include "LogIn.h"
#include "Registration.h"
#include "Events.h"
#include "Competition.h"
using namespace std;
vector<Competition> CompPop()
{
ifstream myfile("PSU Results.txt");
string line, tcomp, tleader, tfollower, tevents, tplacement;
vector<Competition> info;
if(myfile.is_open())
{
int i = 0; // finds first line
int n = 0; // current vector index
int space;
while(!myfile.eof())
{
getline(myfile,line);
if(line[i] == '*')
{
space = line.find_first_of(" ");
tleader = line.substr(0+1, space);
tfollower = line.substr(space + 1, line.size());
}
else
{
if(line[i] == '-')
{
tcomp = line.substr(1, line.size());
Competition temp(tcomp, tleader, tfollower);
info[n] = temp;
}
else
{
if(!line.empty())
{
line = line;
space = line.find_first_of(",");
tevents = line.substr(0, space);
tplacement = line.substr(space + 2, line.size());
info[n].pushEvents(tevents,tplacement);
}
if(line.empty())
{
n++;
}
}
}
}
}
else
{
cout << "Unable to open file";
}
myfile.close();
return info;
}
My Competition Header (Similar to my Registration header):
#pragma once
#include <fstream>
#include <sstream>
#include <iostream>
#include <string>
#include <vector>
#include "LogIn.h"
#include "Registration.h"
#include "Events.h"
using namespace std;
struct Competition
{
public:
Competition(string compName, string lead, string follow)
{
Name = compName;
Leader = lead;
Follower = follow;
}
void pushEvents(string name, string place)
{
Events one(name, place);
Eventrandom.push_back(one);
}
string GetName()
{
return Name;
}
string GetLeader()
{
return Leader;
}
string GetFollow()
{
return Follower;
}
string GetEvent()
{
return Event;
}
string GetScore()
{
return Score;
}
void Print()
{
cout << "Leader: " << Leader << endl;
cout << "Follower: " << Follower << endl;
cout << "Competition: " << Name << endl;
cout << "Events and Placement: " << endl;
for(vector<Events>::iterator pos = Eventrandom.begin(); pos != Eventrandom.end(); ++pos)
{
cout << pos->eventName << " " << pos->Placement << endl;
}
cout << endl;
}
~Competition();
private:
string Name, Leader, Follower, Event, Score;
vector<Events> Eventrandom;
};
My Registration header:
#pragma once
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
#define MAX_LENGTH 7
#define MAX_DANCES 9
class Registration
{
public:
Registration();
Registration(string confirmationCode, string follower, string leader, string comp, string level, string dance);
void FirstTime();
void infoFollower();
void infoLeader();
string gen_random(const int len);
string Levels();
string Dances();
void Print();
void print2Confirmation();
~Registration();
private:
string CCode, Follower, Leader, Name;
string Level, Dance;
};
المحلول
The error messages are pretty clear.
unresolved external symbol "public: __thiscall Registration::~Registration(void)"
Registration::~Registration(void)
is the destructor of the Registration
class. Have you defined one?