筱羅卜 2015-06-08 09:02 采纳率: 100%
浏览 2766
已采纳

这是什么错误啊??求大神指教,

--------------------Configuration: zy1 - Win32 Debug--------------------
Compiling...
1.cpp
D:\VC++6.0\Microsoft Visual Studio\MyProjects\zy1\1.cpp(47) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
执行 cl.exe 时出错.

1.obj - 1 error(s), 0 warning(s)

  • 写回答

3条回答 默认 最新

  • 筱羅卜 2015-06-08 09:48
    关注

    /*1.已知一个有理数类zrf_Ratio,包含私有数据成员:分子num和分母den, 以及公有函数成员 friend ostream& operator<<(ostream& ostr, const zrf_Ratio& r) { return ostr << r.num << "/" << r.den;} 请补充该类的构造函数,并实现如下的操作符重载形式: friend zrf_Ratio operator-(const zrf_Ratio&); friend zrf_Ratio operator+(const zrf_Ratio&, const zrf_Ratio&); friend zrf_Ratio operator-(const zrf_Ratio&, const zrf_Ratio&); friend zrf_Ratio operator*(const zrf_Ratio&, const zrf_Ratio&); friend zrf_Ratio operator/(const zrf_Ratio&, const zrf_Ratio&);*/

    #include
    using namespace std;
    int f1()
    { int m,n,t;
    cout<<"请输入两个数:";
    cin>>m>>n;

    while(n!=0)
    { t=m%n; m=n; n=t; }
    return m;
    }

    class zrf_Ratio
    {
    public:

    friend ostream& operator<<(ostream& ostr, const zrf_Ratio& r)
    { return ostr << r.num << "/" << r.den;}

    friend zrf_Ratio operator-(const zrf_Ratio& r0 )
    {return zrf_Ratio(-r0.num,r0.den);}

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

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

    friend zrf_Ratio operator*(const zrf_Ratio& r1, const zrf_Ratio& r2)

    { int a=f1(r1.den,r2.den); while(a!=1) { r1.num*r2.num/=d; r1.den*r2.den/=d; d=f1(r1.num*r2.num,r1.den*r2.den); } return zrf_Ratio(r1.num*r2.num,r1.den*r2.den); }

    friend zrf_Ratio operator/(const zrf_Ratio& r1, const zrf_Ratio& r2)
    {return r1*zrf_Ratio(r2.num,r2.den);}
    private:
    int num,den;
    };
    int mian()
    {
    zrf_Ratio m(3,7);

    zrf_Ratio n(4,9);

    p(-a);

    p(a+b);

    p(a-b);

    p(a*b);

    p(a/b);

    return 0; }
    就是这个题目,这代码肯定有好多错误,希望前辈可以耐心指教,谢谢

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

报告相同问题?

悬赏问题

  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R