给定一个函数的定义,当两个边作为参数给出时,在屏幕上打印出矩形的剩余两条边:
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;
}
你可以告诉我,我做错了什么?谢谢!
答案 0 :(得分:3)
void restPuncte (Punct &x, Punct &y)
与
不同void Punct::restPuncte (Punct &x, Punct &y)
您正在定义一个免费功能,而您的static
方法仍未定义。