(4) 定义一个分数类如下,要求实现各个成员函数,并在主函数中测试两个分数的加减乘除等运算。
cpp
class Rational { public: Rational(int nn=1,int mm=1); //构造函数 Rational R_add(Rational & A); //加 Rational R_sub(Rational & A); //减 Rational R_mul(Rational & A); //乘 Rational R_p(Rational & A); //除 void print(); //以简分数形式显示,注意约分 private: void simple( ); //约分 int m; //分母 int n; //分子 };
How to use:
Looking at this mentally handicapped problem, it should be like an assignment in the school C++ textbook. Brother, you also need someone to do your homework for you. Is this really good? ?
haha A random search on the Internet for this computer question will yield results. Do you still need to ask? .