0

I'm getting all these errors:

undefined reference to 'getLength()'
undefined reference to 'getWidth()'
undefined reference to 'getArea(double, double)'
undefined reference to 'displayData(double, double, double)'

Here's my code:

#include <iostream>

using namespace std;

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

int main()
{
    double length;
    double width;
    double area;

    length = getLength();
    width = getWidth();
    area = getArea(length,width);
    displayData(length,width,area);

    return 0;
}

//getLength function
double getLength();
{

    double length;
    cout << "Length: ";
    cin >> length;

    return length;

}

//getWidth function
double getWidth();
{
    double width;
    cout << "Width: ";
    cin >> width;

    return width;
}

//GetArea function
double getArea(double lenght, double width);
{
    return length*width;
}

//displayData function
void displayData(double length, double width, double area);
{
    cout << "\nRectangle Data\n"
        << "---------------\n"
        << "Length: " << length << endl
        << "Width: " << width << endl
        << "Area: " << area << endl;

}
Alejandro
  • 7,290
  • 4
  • 34
  • 59

2 Answers2

6

Other than missing a parenthesis (}) at the end of main, you shouldn't have semicolons in your function definitions:

double getLength(); <-- should not be there
{
    ....
}
yizzlez
  • 8,757
  • 4
  • 29
  • 44
  • Didn't see that error ! Nice one ! However he is not missing a parenthesis at the end of the main ;-) but rather a bracket :-) – LBes Jul 07 '15 at 22:54
1

The format of your code is awful please make it better so we can help you.

However from what I'm seeing the problem is that your functions are not defined when you try to call them. Before your main give the prototype of your functions and then you c an implement them even after the main function.

EDIT: from what I'm seeing there may be one missing } at the end of your main function which therefore will make your other functions implementations somehow "nested" ( don't know if that's the word to use here ). Yet I am not sure about that as your formatting is not good at all and your code is therefore not really readable.

Hope it helps.

LBes
  • 3,366
  • 1
  • 32
  • 66
  • yea sorry im new to all this so my formatting skills are pretty much shit. thanks for the help though – Mikey Larragueta Jul 07 '15 at 22:53
  • No problem but please correct your post so that it is readable for future users. Also note the additional info provided in the other answer: get rid of the semi-colons at the end of the function definition. Finally when an answer was helpful please accept it as an answer :-) – LBes Jul 07 '15 at 22:56
  • i will gladly fix it. but what is wrong? – Mikey Larragueta Jul 07 '15 at 22:59
  • The things I told you in my answer AND comment and that were also underlined by @awesomeyi – LBes Jul 07 '15 at 23:03