未明确引用'(我的所有功能)'

Mik*_*eta -2 c++

我收到所有这些错误:

未定义引用'getLength()'
未定义引用'getWidth()'
未定义引用'getArea(double,double)'
未定义引用'displayData(double,double,double)'

这是我的代码:

#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;

}
Run Code Online (Sandbox Code Playgroud)

yiz*_*lez 6

除了}在main的末尾缺少一个括号()之外,你的函数定义中不应该有分号:

double getLength(); <-- should not be there
{
    ....
}
Run Code Online (Sandbox Code Playgroud)