标题:程序编译错误, 求解!
只看楼主
yang400b
Rank: 2
等 级:论坛游民
帖 子:14
专家分:17
注 册:2012-6-13
结帖率:100%
已结贴  问题点数:10 回复次数:2 
程序编译错误, 求解!
#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'
搜索更多相关主题的帖子: double Documents include public 
2012-06-15 16:35
lonmaor
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:郑州
等 级:版主
威 望:75
帖 子:2637
专家分:6423
注 册:2007-11-27
得分:10 
rectangle类用到point类型了,所以需要在之前定义一下。

从不知道到知道,到知道自己不知道,成长的道路上脚步深深浅浅
2012-06-15 16:42
yang400b
Rank: 2
等 级:论坛游民
帖 子:14
专家分:17
注 册:2012-6-13
得分:0 
OK谢谢!
2012-06-15 17:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-371599-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.188549 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved