筱羅卜 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 求数学坐标画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站