mercredi 21 janvier 2015

C++ Homework giving LNK2019: unresolved external symbol error

Hey guys I'm fairly new to C++ and wondering if you guys can help me with my homework?It's basically a money converter for pounds and euros but when I compile I get this:


1> HwkJohn.cpp 1>HwkJohn.obj : error LNK2019: unresolved external symbol "void __cdecl convertPriceIntoEuros(void)" (?convertPriceIntoEuros@@YAXXZ) referenced in function "void __cdecl processAPrice(void)" (?processAPrice@@YAXXZ) 1>HwkJohn.obj : error LNK2019: unresolved external symbol "void __cdecl showPriceInEuros(void)" (?showPriceInEuros@@YAXXZ) referenced in function "void __cdecl processAPrice(void)" (?processAPrice@@YAXXZ) 1>HwkJohn.obj : error LNK2019: unresolved external symbol "void __cdecl calculateSum(void)" (?calculateSum@@YAXXZ) referenced in function "void __cdecl processAPrice(void)" (?processAPrice@@YAXXZ) 1>HwkJohn.obj : error LNK2019: unresolved external symbol "void __cdecl displayFinalData(void)" (?displayFinalData@@YAXXZ) referenced in function "void __cdecl processAPrice(void)" (?processAPrice@@YAXXZ) 1>c:\users\john\documents\visual studio 2012\Projects\HwkJohn\Debug\HwkJohn.exe : fatal error LNK1120: 4 unresolved externals


spent a few hours googling this definition but I don't understand it if anyone could help? Were also not allowed to use any global variables in the program.



#include <iostream> //for cin >> and cout <<
#include <cassert> //for assert
#include <iomanip>

using namespace std;

void processAPrice();
double getPriceInPounds();
void convertPriceIntoEuros();
void showPriceInEuros();
void calculateSum();
void displayFinalData();

int main()
{
char answer;
float numberOfPrices = 0.0;


while (&(answer = 'Y') || (answer = 'y'))
{
processAPrice();
numberOfPrices += 1;
cout << "Continue (Y/N)";
cin >> answer;
}

if (numberOfPrices > 0)
{
// displayFinalData;

}


return 0;

}

void processAPrice()
{
getPriceInPounds();
convertPriceIntoEuros();
showPriceInEuros();
calculateSum();
displayFinalData();
}

double getPriceInPounds()
{
double priceInPounds;

cout << "Enter a price (in pounds): £";
cin >> priceInPounds;

return priceInPounds;
}

double convertPriceIntoEuros(double priceInPounds)
{
double priceInEuros = 0.0;
const double conversionRate = 0.82;

priceInEuros = priceInPounds / conversionRate;
return priceInEuros;
}

double showPriceInEuros(double priceInPounds, double priceInEuros)
{
cout << "The euro value of £:", priceInPounds, " is €", priceInEuros;
return priceInEuros;
}

double calculateSum(double priceInEuros)
{
double sumInEuros = 0.;
sumInEuros = sumInEuros + priceInEuros;
return sumInEuros;
}

double displayFinalData(double numberOfPrice, double sumInEuros)
{
cout << "The total sum is:", sumInEuros, "€";
cout << "The average is: ", sumInEuros/numberOfPrice;

return 0;
}

Aucun commentaire:

Enregistrer un commentaire