0

Hello, I'm just learning C++ and I'm getting an error with a program that is driving me nuts, and I'm not exactly sure how to resolve it. Can anyone help me?

AreaCalculator.obj : error LNK2019: unresolved external symbol "double __cdecl AreaOfTriangle(double,double)" (?AreaOfTriangle@@YANNN@Z) referenced in function _main

\\.psf\Home\Documents\Visual Studio 2008\Projects\AreaCalculator\Debug\AreaCalculator.exe : fatal error LNK1120: 1 unresolved externals

```
#include <iostream> //for using cin and cout
#include <conio.h> //for using getch()
#include <cmath> //for using pow
using namespace std;
double AreaOfRectangle(/* in */ double length, //length of rectangle
/* in */ double width); //width of rectangle
//Purpose: Calculate the area of a rectangle
//Precondition:
// length and width are assigned the length and width of the rectangle.
// length > 0 and width > 0
//Postcondition:
// Returns the area of the rectangle
double AreaOfCircle(/* in */ double radius); //radius of circle
//Purpose: Calculate the area of a circle
//Precondition:
// radius is assigned the radius of the circle.
// radius > 0
//Postcondition:
// Returns the area of the circle.
double AreaOfTriangle (/* in */ double base, //length of triangle base
/* in */ double height); //height of triangle
//Purpose: Calculate the area of a triangle
//Precondition:
// base and height are assigned the base and height of the triangle
// base > 0 and height > 0
//Postcondition:
// Returns the area of the triangle.
int main()
{
double radius; //radius of circle
double length; //length of rectangle
double width; //width of rectangle
double base; //base length of triangle
double height; //height of triangle
int number; //number entered to indicate user's selection
//display a heading
cout << "*** Calculation of area ***\n\n\n";
//Ask user to enter 1 or 2 and read the number
cout << "Enter 1 to calculate the area of a rectangle, \n";
cout << " 2 to calculate the area of a circle, or\n";
cout << " 3 to calculate the area of a triangle.\n\n";
cout << "Please enter 1, 2, or 3: ";
cin >> number;
cout << endl;
//calculate area of rectangle or area of circle
if (number == 1) //for calculating the area of rectangle
{
//prompt for and read the length and width of rectangle
cout << "Enter the length of the rectangle in inches: ";
cin >> length;
cout << "Enter the width of the rectangle in inches: ";
cin >> width;
//Call function to calculate area of rectangle, and display the area
cout << endl << "Area of rectangle is: " << AreaOfRectangle(length,width)
<< " square inches.\n\n";
}
else if (number == 2 ) //for calculating the area of circle
{
//prompt for and read the radius of circle
cout << "Enter the radius of the circle in inches: ";
cin >> radius;
//Call function to calculate area of circle, and display the area
cout << endl << "Area of circle is " << AreaOfCircle(radius) << " square inches.\n\n";
}
else if (number == 3) //for calculating the area of a triangle
{
//prompt for and read the base and height of the triangle
cout << "Enter the base of the triangle in inches: ";
cin >> base;
cout << "Enter the height of the triandgle in inches: ";
cin >> height;
//Call the function to calculate the area of a triangle, and display the area
cout << endl << "Area of triangle is " << AreaOfTriangle(base,height) << "square inches.\n\n";
}
else
cout << "Invalid number entered. \n\n"; //number other than 1 and 2 entered
_getch(); //to hold the screen for viewing
return 0;
}
//-----------------------------------------------------------------------------------
double AreaOfRectangle(/* in */ double length, //length of rectangle
/* in */ double width ) //width of rectangle
{
double areaRect; //area of rectangle
//calculate the area
areaRect = length * width;
return areaRect;
}
//-------------------------------------------------------------------------------------
double AreaOfCircle(/* in */ double radius ) //radius of circle
{
const double PI = 3.14159;
double areaCirc; //area of circle
//calculate area of circle
areaCirc = PI * pow(radius,2.0); //note the use of the predefined function pow
return areaCirc;
}
//--------------------------------------------------------------------------------------
double AreaOfTrianglw(/* in */ double base, //length of base of triangle
/* in */ double height) //height of triangle
{
double areaTri; //area of triangle
//calculate area of triangle
areaTri = (base * height) / 2;
return areaTri;
}
```

Thanks!