程序编译错误, 求解!
#include<iostream>using namespace std;
class rectangle
{ public:
void area(point t)
{ cout<<(t.y1-t.y)*(t.x1-t.x)<<endl; }
};
class point
{ friend rectangle;
double x,y,x1,y1;
public:
point(double a,double b,double c,double d)
{
x=a; y=b; x1=c; y1=d;
}
};
int main()
{ double a,b,c,d;
cin>>a>>b>>c>>d;
rectangle t1;
point t2(a,b,c,d);
t1.area(t2);
return 0;
}
5 C:\Documents and Settings\Administrator\桌面\bj.cpp variable or field `area' declared void
5 C:\Documents and Settings\Administrator\桌面\bj.cpp expected `;' before '(' token
7 C:\Documents and Settings\Administrator\桌面\bj.cpp expected `;' before '}' token
9 C:\Documents and Settings\Administrator\桌面\bj.cpp a class-key must be used when declaring a friend
C:\Documents and Settings\Administrator\桌面\bj.cpp In function `int main()':
22 C:\Documents and Settings\Administrator\桌面\bj.cpp 'class rectangle' has no member named 'area'