这个程序问题出在哪呢?没有编译错误,但运行乱码。。是主函数的问题吗?

#include
using namespace std;
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& z1)
{
    zrf_Ratio a;
    return a.f1(zrf_Ratio(num+z1.num,den+z1.den));
}

zrf_Ratio& operator*=(const zrf_Ratio& z2)
{
    zrf_Ratio a;
    return a.f1(zrf_Ratio(z2.num*z2.den,z2.den+z2.den));
}

zrf_Ratio& operator++()
{
    num++;
    den++;
    return *this;
}

zrf_Ratio operator++(int)
{
        zrf_Ratio a;
        a=*this;
        ++ * this;
        return a;
}

private:
int num,den;
};
int main()
{
zrf_Ratio x(2,7),y(3,5),z;
z=x.operator=(y);
cout<<"x=(y)="<<z<<endl;
z=x*=(y);
cout<<"x*=(y)="<<z<<endl;
z++;
cout<<"z="<<z<<endl;
++z;
cout<<"z="<<z<<endl;
return 0;
}

运行乱码,是因为你代码访问的字符等编码是不是没有处理好

    zrf_Ratio(int r1,int r2):num(r1),den(r2){}

这句什么意思?

++ * this; 这句不对吧,this 指针自加一后指向哪里呢?不能这样改变 this 指针的值。

++ * this 有问题,不能这么写。

    #include <iostream>
    using namespace std;

    class zrf_Ratio
    {
        public:
            zrf_Ratio(){}
            zrf_Ratio(int r1,int r2):num(r1),den(r2){}
            zrf_Ratio& f1(zrf_Ratio& z)
            {
                cout<<"DEBUG:f1("<<z.num<<"/"<<z.den<<")"<<endl;
                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;
            }
            void print()
            { 
                printf("%d/%d\n", num, den);
            }
            friend ostream& operator<<(ostream& ostr, const zrf_Ratio& r)
            { return ostr << r.num << "/" << r.den;}

            /*
            zrf_Ratio operator=(const zrf_Ratio& z1)
            {
                zrf_Ratio a;
                return a.f1(zrf_Ratio(num+z1.num,den+z1.den));
            }
            */
            zrf_Ratio& operator*=(const zrf_Ratio& z2)
            {
                zrf_Ratio a;
                return a.f1(zrf_Ratio(z2.num*z2.den,z2.den+z2.den));
            }

            zrf_Ratio& operator++()
            {
                ++num;
                ++den;
                return *this;
            }

            const zrf_Ratio operator++(int)
            {
                    zrf_Ratio a(*this);
                    ++ (*this);
                    return a;
            }
        private:
            int num,den;
    };

    int main()
    {
        zrf_Ratio x(2,7),y(3,5),z;
        /*
        z=x.operator=(y);
        cout<<"x=(y)="<<z<<endl;
        */
        cout<<"x="<<x<<endl;
        cout<<"y="<<y<<endl;
        z=x*=(y);
        cout<<"x*=(y)="<<z<<endl;

        cout<<"z++="<<z++<<endl;
        cout<<"z="<<z<<endl;

        cout<<"++z="<<++z<<endl;
        cout<<"z="<<z<<endl;
        return 0;
    }

错误原因是你重载了=,导致给z赋值还是要调用重载,所以只有++自运算才是正确的。
去掉后输出就正常了。

    x=2/7
    y=3/5
    DEBUG:f1(15/10)
    x*=(y)=3/2
    z++=3/2
    z=4/3
    ++z=5/4
    z=5/4
    Press any key to continue

乱码的话,你改一下你文件的编码方式试试