I have encountered an error which has stumped me for many days now. A quick google hasn't given me an answer. The code, to my eyes, has no errors however when I run the program I get 9 Unresolved External Symbol(LNK2019) error. After trying to decipher one of my errors, I believe it is happening in a function named createMortgage
. Here is my calling of the function.
customers
is a Vector.
for (unsigned int i = 0; i < customers.size(); i++)
{
Customer tempcust = customers.at(i);
if (tempcust.getId() == id)
{
customers.at(i).createMortgage();
}
}
Here is the function itself.
void createMortgage(){
int amount;
cout << "Amount?";
cin >> amount;
Mortgage mort(amount);
mortgages.push_back(mort);
}
And here, in all it's glory, is the error.
Error 4 error LNK2019: unresolved external symbol "public: __thiscall Mortgage::Mortgage(double)" (??0Mortgage@@QAE@N@Z) referenced in function "public: void __thiscall Customer::createMortgage(void)" (?createMortgage@Customer@@QAEXXZ) F:\C++ assignment (Real)\C++ assignment (Real)\Driver.obj C++ assignment (Real)
Here is my mortgage .h file.
#pragma once
//#include <iostream>
//#include <String>
class Mortgage
{
private:
int id;
double amount;
public:
Mortgage(double amount);
double getAmount();
int getId();
};
And here is my mortgage .cpp file.
#pragma once
extern int idcreation;
class Mortgage
{
int id;
double amount;
Mortgage(double amount)
{
this -> amount = amount;
this -> id = idcreation;
idcreation++;
}
int getId(){
return id;
}
double getAmount(){
return amount;
}