错误引用自:

时间:2013-02-27 16:39:48

标签: c++ build

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

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

在main中我在尝试构建项目时遇到以下错误:

"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;
}
你可以告诉我,我做错了什么?谢谢!

1 个答案:

答案 0 :(得分:3)

void restPuncte (Punct &x, Punct &y)

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

您正在定义一个免费功能,而您的static方法仍未定义。