1

给定一个函数的定义,当两个边作为参数给出时,它会在屏幕上打印出矩形的剩余两条边:

static void restPuncte (Punct &x, Punct &y);

及其实施:

void restPuncte (Punct &x, Punct &y)
{
    Punct c;
    c.MutaX(x.GetX());
    c.MutaY(y.GetY());

    Punct d;
    d.MutaX(y.GetX());
    d.MutaY(x.GetY());

    std::cout << "Punctul C este:" << c << std::endl;
    std::cout << "Punctul D este:" << d << std::endl;
}

在尝试构建项目时,主要出现以下错误:

"Punct::restPuncte(Punct&, Punct&)", referenced from:

主要是:

#include <iostream>
#include "punct.h"

using namespace std;

int main ()
{

    Punct firstPoint(1,2);

    Punct thirdPoint(4,3);

    cout << "Determinarea celorlalte doua colturi" << endl;
    cout << "Cele doua puncte sunt:" << firstPoint << " si " << thirdPoint <<endl;
    Punct::restPuncte(firstPoint,thirdPoint);


    return 0;
}

你能告诉我我做错了什么吗?谢谢!

4

1 回答 1

3
void restPuncte (Punct &x, Punct &y)

不一样

void Punct::restPuncte (Punct &x, Punct &y)

您正在定义一个自由函数,而您的static方法仍未定义。

于 2013-02-27T16:41:35.543 回答