zoukankan      html  css  js  c++  java
  • 随笔

    class Rational
    {
    public:
        Rational(int numerator = 0, int denominator = 1);
        int numerator() const;
        int denominator() const;
        
    private:
    };
    
    const Rational operator*(const Rational& lhs, const Rational& rhs)
    {
        return Rational(lhs.numerator() * rhs.numerator(), lhs.denominator() * rhs.denominator());
    }
    int main()
    {
        Rational oneEighth(1, 8);
        Rational oneHalf(1, 2);
        Rational result = oneHalf * oneEighth;
        result = result * oneEighth;
        result = oneHalf * 2;//让两个参数都通过隐式转换
        result = 2 * oneHalf;
        return 0;
    }
  • 相关阅读:
    POJ 2136
    POJ 2121
    POJ 2127
    POJ 2126
    POJ 2109
    POJ 2105
    POJ 2101
    POJ 2075
    Uboot — 配置过程
    Uboot — 编译体验
  • 原文地址:https://www.cnblogs.com/zzyoucan/p/6592472.html
Copyright © 2011-2022 走看看