筱羅卜 2015-06-09 05:34 采纳率: 100%
浏览 1694
已采纳

编译时出现这样的错误,求大神指点解决方法

程序如下:
#include
using namespace std;
class zrf_Ratio;
zrf_Ratio operator+(const zrf_Ratio& r1, const zrf_Ratio& r2);
zrf_Ratio operator-(const zrf_Ratio&, const zrf_Ratio&);
zrf_Ratio operator*(const zrf_Ratio&, const zrf_Ratio&);
zrf_Ratio operator/(const zrf_Ratio&, const zrf_Ratio&);

class zrf_Ratio
{
public:
zrf_Ratio(){}
zrf_Ratio(int r1,int r2):num(r1),den(r2){}
zrf_Ratio f1(zrf_Ratio& z)
{
int r,m=z.num,n=z.den;
while(r=z.num%z.den)
{
z.num=z.den;
z.den=r;
}
r=z.den;
z.num=m/r;
z.den=n/r;
return z;
}
friend ostream& operator<<(ostream& ostr, const zrf_Ratio& r)
{ return ostr << r.num << "/" << r.den;}

zrf_Ratio operator-(const zrf_Ratio& r1)
{return f1(zrf_Ratio(num*r1.den-r1.num*den,den*r1.den));}

friend zrf_Ratio operator+(const zrf_Ratio& r1, const zrf_Ratio& r2)
{
    zrf_Ratio a;
    return a.f1(zrf_Ratio(r1.num*r2.den+r2.num*r1.den,r1.den*r2.den));
}

friend zrf_Ratio operator-(const zrf_Ratio& r1, const zrf_Ratio& r2)
{
    zrf_Ratio a;
    return a.f1(zrf_Ratio(r1.num*r2.den-r2.num*r1.den,r1.den*r2.den));
}

friend zrf_Ratio operator*(const zrf_Ratio& r1, const zrf_Ratio& r2)
{
    zrf_Ratio a;
    return a.f1(zrf_Ratio(r1.num*r2.num,r1.den*r2.den));
}

friend zrf_Ratio operator/(const zrf_Ratio& r1, const zrf_Ratio& r2)
{
    zrf_Ratio a;
    return a.f1(zrf_Ratio(r1.num*r2.den,r1.den*r2.num));
}

private:
int num,den;
};
int mian()
{
zrf_Ratio x(3,7),y(4,9),z;
z=x.operator-(y);
cout<<"x-y="<<z<<endl;
z=x+y;
cout<<"x+y="<<z<<endl;
z=x-y;
cout<<"x-y="<<z<<endl;
z=x*y;
cout<<"x*y="<<z<<endl;
z=x/y;
cout<<"x/y="<<z<<endl;
return 0;
}
显示错误如下:
Deleting intermediate files and output files for project '2 - Win32 Debug'.
--------------------Configuration: 2 - Win32 Debug--------------------
Compiling...
2.cpp
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/2.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.

2.exe - 1 error(s), 0 warning(s)

  • 写回答

2条回答 默认 最新

  • threenewbee 2015-06-09 05:39
    关注

    main拼写错了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)