I've worked this over including retyping, I would like some advice as to what I should be looking for in this error. Thank You. Here is the full message:
error LNK2019: unresolved external symbol "double __cdecl getArea(void)" (?getArea@@YANXZ) referenced in function _main
: fatal error LNK1120: 1 unresolved externals
#include <iostream>
using namespace std;
// Write the prototypes for the getLength,
// getWidth, getArea, and displayData
// functions here.
double getLength(),
getWidth(),
getArea();
void 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;
}
//***************************************************
// You must write the getLength, getWidth, getArea, *
// and displayData functions. *
//***************************************************
double getLength()
{
double length;
cout << "Enter the length of the rectangle: ";
cin >> length;
return length;
}
double getWidth()
{
double width;
cout << "Enter the width of the rectangle: ";
cin >> width;
return area;
}
void displayData(double length, double width, double area)
{
cout << "\nThe length of the rectangle: " << length << endl;
cout << "The width of the rectangle: " << width << endl;
cout << "The area of the rectangle is: " << area << endl;
You are forgetting to specify the return types of your function prototypes. You are also not specifing the right parameters in your prototypes either.
1 2 3 4 5 6 7
// Write the prototypes for the getLength,
// getWidth, getArea, and displayData
// functions here.
double getLength(), // You need a semicolon here not a comma
getWidth(), // again you need a semicolon not a comma
getArea(); // forgot to add the return type and parameters.
void displayData(double, double, double);
Notice how you defined the return type for displayData but not the return type for your other function prototypes.
They should look like this
1 2 3 4 5
double getLength();
double getLength();
// You forgot the parameters on this function prototype.
double getArea(double length, double width);
void displayData(double length, double width, double area);
When you declare function prototypes you only need to have the parameter types in it but it will help anyone that reads your program's source code if they also have the parameter names in them to.
Also when posting code to the forum please use the codetags feature otherwise it is harder to read your code.
Actually the unresolved external errors basically means that the compiler has no idea what getArea is because the function prototype is wrong (In the return type and the parameters), it doesn't really have anything to do with the function call though the call to the function is wrong also like you said.
Once he fixes the function prototype errors and then runs the program again he will get a error message something like
error: too few arguments to function 'double getArea(double, double)
I thank you for your input, you have taught me a programming concept that I was missing and which will carry me all through programming. With the knowledge you presented me I was able to figure out the error you pointed out to me. I'll make future use of the codetags feature, I'm new to this.