小编Kun*_*lin的帖子

分数运算符

我需要编写一个程序来计算分数,这是我的头文件:

#ifndef FRACTION_H
#define FRACTION_H
#include <iostream>
#include <string>
using namespace std;

class Fraction {

    private:
        int *numer;
        int *denom;
        int gcd(int, int);
    public:
        void reduce();
        int getNum();
        int getDen();
        Fraction();
        Fraction(int numerator);
        Fraction(int num, int den);
        Fraction(string s);  // take string parameter of the form of "numerator/defnominator
        Fraction(Fraction &other);  // copy constructor
        Fraction & operator=(Fraction & rhs);
        ~Fraction();
        // overloading arithematic operation
        Fraction & operator+ (Fraction & rhs);
        Fraction & operator- (Fraction & rhs);
        Fraction & operator* (Fraction & …
Run Code Online (Sandbox Code Playgroud)

c++ string class operator-keyword

0
推荐指数
1
解决办法
4415
查看次数

标签 统计

c++ ×1

class ×1

operator-keyword ×1

string ×1