1

2つのエッジが引数として指定されている場合に、長方形の残りの2つのエッジを画面に出力する関数の定義を考えると、次のようになります。

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 に答える