求大神帮我改改c++程序,总是停止运行!

#include
using namespace std;
class Fraction
{
private:
int num,den;
void normalize();
int gcf(int a,int b);
int lcm(int a,int b);
public:
Fraction() {set(0,1);cout<<"construct"<<endl;}
Fraction(int n,int d){set(n,d);cout<<"construct"<<endl;}
Fraction(Fraction &src);
void set(int n,int d)
{ num=n;den=d;normalize();}
int get_num() {return num;}
int get_den() {return den;}
Fraction add(Fraction other);
Fraction mult(Fraction other);
};
Fraction::Fraction(Fraction &src){
cout<<"Now calling copy constructor."<<endl;
num=src.num;
den=src.den;
}

void Fraction::normalize(){
if(den==0||num==0){
num=0;
den=0;
}
if(den<0){
num*=-1;
den*=-1;
}
int n=gcf(num,den);
num=num/n;
den=den/n;
}
int Fraction::gcf(int a,int b){
if(b==0)
return abs(a);
else
return gcf(b,a%b);
}
int Fraction::lcm(int a,int b){
int n=gcf(a,b);
return a/n*b;
}
Fraction Fraction::add(Fraction other){
Fraction fract;
int lcd=lcm(den,other.den);
int quot1=lcd/den;
int quot2=lcd/other.den;
fract.set(num*quot1+other.num*quot2,lcd);
return fract;
}
Fraction Fraction::mult(Fraction other)
{
Fraction fract;
fract.set(num*other.num,den*other.den);
return fract;
}

int main()
{
Fraction f1(3,4);
Fraction f2(f1);
Fraction f3=f1.add(f2);
cout<<"The value is";
cout<<f3.get_num()<<"/";
cout<<f3.get_den()<<endl;
system("PAUSE");
return 0;
}

void Fraction::normalize(){
if(den==0||num==0){
num=0; //这里把分子分母设置成了0,下面出现除0错误
den=0;
}
if(den<0){
num*=-1;
den*=-1;
}
int n=gcf(num,den);
num=num/n; //这里出现除0错误
den=den/n;
}

都已经判断了分子或分母为0,了你不用else,后面还要参加运算,不是肯定会出错的么?

#include <iostream>
using namespace std;
class Fraction
{
private:
    int num, den;
    void normalize();
    int gcf(int a, int b);
    int lcm(int a, int b);
public:
    Fraction() { set(0, 1); cout << "construct" << endl; }
    Fraction(int n, int d){ set(n, d); cout << "construct" << endl; }
    Fraction(Fraction &src);
    void set(int n, int d)
    {
        num = n; den = d; normalize();
    }
    int get_num() { return num; }
    int get_den() { return den; }
    Fraction add(Fraction other);
    Fraction mult(Fraction other);
};
Fraction::Fraction(Fraction &src){
    cout << "Now calling copy constructor." << endl;
    num = src.num;
    den = src.den;
}
void Fraction::normalize(){
    if (den == 0 || num == 0){
        num = 0;
        den = 0;
    }
    else //都已经判断了分子或分母为0,了你不用else,后面还要参加运算,不是肯定会出错的么?
    {
        if (den < 0){
            num *= -1;
            den *= -1;
        }
        int n = gcf(num, den);
        num = num / n;
        den = den / n;
    }
}
int Fraction::gcf(int a, int b){
    if (b == 0)
        return abs(a);
    else
        return gcf(b, a%b);
}
int Fraction::lcm(int a, int b){
    int n = gcf(a, b);
    return a / n*b;
}
Fraction Fraction::add(Fraction other){
    Fraction fract;
    int lcd = lcm(den, other.den);
    int quot1 = lcd / den;
    int quot2 = lcd / other.den;
    fract.set(num*quot1 + other.num*quot2, lcd);
    return fract;
}
Fraction Fraction::mult(Fraction other)
{
    Fraction fract;
    fract.set(num*other.num, den*other.den);
    return fract;
}
int main()
{
    Fraction f1(3, 4);
    Fraction f2(f1);
    Fraction f3 = f1.add(f2);
    cout << "The value is";
    cout << f3.get_num() << "/";
    cout << f3.get_den() << endl;
    system("PAUSE");
    return 0;
}