Linker error undefined reference to 'program'

Using DevC++ and trying to compile my program. Keep getting an error message each time I try. No idea how to fix this am fairly new to C++ so any help would be greatly appreciated.


#include <iostream>
using namespace std;

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

int main()
{
double length; // The rectangle's length
double width; // The rectangle's width
double area; // The rectangle's area

// Get the rectangle's length.
length = getLength();
{
cout << "Input the length:" << endl;
cin >> length;
if(length > 0)
cout << "Thank you" << endl;
else;
cout << "Invalid input." << endl;
}
// Get the rectangle's width.
width = getWidth();
{
cout << "Input the width:" << endl;
cin >> width;
if(width <= 0)
cout << "Thank you" << endl;
else;
cout << "Invalid input." << endl;
}
// Get the rectangle's area.
area = getArea();
{
area = length * width;
}

// Display the rectangle's data.
double displayData(double length, double width, double area);
{
cout << "The length is: " << length << endl;
cout << "The width is: " << width << endl;
cout << "The area is: " << area << endl;
}

system("pause");
return 0;
}
error reads as:
[Linker error] undefined reference to `getLength()'
[Linker error] undefined reference to `getWidth()'
[Linker error] undefined reference to `getArea()'
ld returned 1 exit status
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
You must define those functions in a correct manner.. :

double length,width,area;
void getLength()
{
   cout << "Input the length:" << endl;
   cin >> length;
   if(length > 0)
        cout << "Thank you" << endl;
   else
       cout << "Invalid input." << endl;
}
void getWidth()
{
...
}
void getArea
{
....
}
double displayData(double length, width, area);
{
cout << "The length is: " << length << endl;
cout << "The width is: " << width << endl;
cout << "The area is: " << area << endl;
}

main()
{
getLength();
getWidth();
getArea();
displayData(length,width,area);
}

There are various errors in your code.. seems to me you are adopting javascript+pascal here..
Topic archived. No new replies allowed.