当我的输入为0.1时,为什么我的答案给出1.49012e

时间:2017-09-08 18:00:08

标签: c++ operator-overloading

#include <iostream>

using namespace std;

class deci {
    float a;
public:
    deci(float b)
    {
        a = b;
    }

    void operator-()
    {
        a = a - 0.1;
        cout << a;
    }
};

int main()
{
    float a;
    cin >> a;

    deci b(a);
    -b;
    return 0;
}

0 个答案:

没有答案