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

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

--------------------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; }
    就是这个题目,这代码肯定有好多错误,希望前辈可以耐心指教,谢谢

    已采纳该答案
    打赏 评论
  • threenewbee 2015-06-08 09:05

    只能看出是链接出错,比如外部函数没有定义,函数名重复,函数定义和申明不一致,全局变量不正确,缺少lib等等都可能会有这种错误。
    贴出你的代码

    打赏 评论
  • frank_20080215 2015-06-08 09:19

    是因为电脑管理权限的问题,用超级管理账户登陆就可以正常使用了。
    When you investigate a possible problem with the Microsoft Visual C++ compiler or linker, it is important to obtain as much information as possible about the build process and the options being used. This article discusses some trouble-shooting tips to help you resolve your build problem.

    打赏 评论

相关推荐 更多相似问题