Oct 15, 2010 at 6:59pm UTC
Hello all...i am really new to C++ programming and i cant figure out why this error keeps popping up...if someone can help, i would really appreciate it
here is my code....compiler says error occurs on line 34:"undefinded reference to findCircleArea (double)...."
#include <iostream>
using namespace std;
void displayMenu();
int getChoice();
void findSquareArea(double);
void findCircleArea(double);
void findTriangleArea(double, double);
int main()
{
const double pi = 3.14159;
double side, radius, length, width;
int choice;
do
{
displayMenu();
choice = getChoice();
if (choice != 4)
{
switch (choice)
{
case 1: cout << "Enter side length: ";
cin >> side;
findSquareArea(side);
break;
case 2: cout << "Enter radius: ";
cin >> radius;
findCircleArea(radius);
break;
case 3: cout << "Enter length and width";
cin >> length >> width;
findTriangleArea(length, width);
}
}
} while (choice != 4);
return 0;
}
void displayMenu()
{
cout << "\nArea Finding Program - Please Select Shape\n\n";
cout << "1 -- square\n";
cout << "2 -- circle\n";
cout << "3 -- right triangle\n";
cout << "4 -- quit";
}
int getChoice()
{
int choice;
cin >> choice;
while (choice < 1 || choice > 4)
{
cout << "The only valid choices are 1-4. Please re-enter. ";
cin >> choice;
}
return choice;
}
void findSquareArea(double side)
{
cout << endl;
cout << "The area of the square is " << side * side;
}
void findCircleArea(double radius, const double pi = 3.14159)
{
cout << endl;
cout << "The area of the circle is " << radius * radius * pi;
}
void findTriangleArea(double length, double width)
{
cout << endl;
cout << "The area of the triangle is " << (length *width)/ 2;
}
Oct 15, 2010 at 7:04pm UTC
Because you haven't written a function findCircleArea (double)