Fatal Error LNK1120

I apologize if this is the wrong thread to put this as this is my first post but I need help with my programming class. I keep getting this error message:

1>a.obj : error LNK2019: unresolved external symbol "double __cdecl getArea(void)" (?getArea@@YANXZ) referenced in function _main

1>c:\users\john salamat\documents\visual studio 2010\Projects\a\Debug\a.exe : fatal error LNK1120: 1 unresolved externals

Please help, thank you.


// Chapter 6, Programming Challenge 2
#include <iostream>
using namespace std;

// Write the prototypes for the getLength,
// getWidth, getArea, and displayData
// functions here.

double getWidth();
double getLength();
double getArea();
double displayData(double, double, double);

int main()

{
double length, // The rectangle's length
width, // The rectangle's width
area; // The rectangle's area

// Get the rectangle's length.
length = getLength();

// Get the rectangle's width.
width = getWidth();

// Get the rectangle's area.
area = getArea();

// Display the rectangle's data.
displayData(length, width, area);

return 0;
}

double getLength()
{
cout << "TESTING ";
double length;
cin >> length;
return length;
}

double getWidth()
{
cout << "MORE TESTING ";
double width;
cin >> width;
return width;
}

double getArea(double length, double width)
{
double area = length * width;
cout << area;
return area;
}

double displayData(double length, double width, double area)
{
cout << length << width << area << endl;
return 0;
}

//***************************************************
// You must write the getLength, getWidth, getArea, *
// and displayData functions. *
//***************************************************
You have a declaration for a function, getArea:

double getArea();

However, there is no definition for that function. You have provided a definition for a function, getArea that takes two doubles, length and width. I believe this is the function you meant to declare above as well as the function you meant to call in main, i.e.:

1
2
// Get the rectangle's area.
area = getArea(length, width);
Thank you, that totally makes sense. I have tried that and it succeeded.
Topic archived. No new replies allowed.